upload test case
This commit is contained in:
@@ -26,6 +26,9 @@ async function init(ctx: VDODOContext): Promise<void> {
|
||||
await ctx.mintTestToken(account0, decimalStr("1000"));
|
||||
await ctx.mintTestToken(account1, decimalStr("1000"));
|
||||
|
||||
await ctx.approveProxy(account0);
|
||||
await ctx.approveProxy(account1);
|
||||
await ctx.approveProxy(account2);
|
||||
}
|
||||
|
||||
describe("VDODO", () => {
|
||||
@@ -48,7 +51,6 @@ describe("VDODO", () => {
|
||||
describe("vdodo", () => {
|
||||
|
||||
it("vdodo init", async () => {
|
||||
|
||||
assert.equal(
|
||||
await ctx.DODO.methods.balanceOf(account0).call(),
|
||||
decimalStr("1000")
|
||||
@@ -69,7 +71,35 @@ describe("VDODO", () => {
|
||||
await ctx.VDODO.methods.totalSupply().call(),
|
||||
decimalStr("0")
|
||||
);
|
||||
|
||||
});
|
||||
it("vdodo first mint with no superior", async () => {
|
||||
|
||||
await ctx.VDODO.methods.mint(decimalStr("10"),"0x0000000000000000000000000000000000000000").send(ctx.sendParam(account0))
|
||||
assert.equal(
|
||||
await ctx.DODO.methods.balanceOf(account0).call(),
|
||||
decimalStr("990")
|
||||
);
|
||||
assert.equal(
|
||||
await await ctx.VDODO.methods.alpha().call(),
|
||||
await ctx.alpha
|
||||
);
|
||||
assert.equal(
|
||||
await ctx.DODO.methods.balanceOf(ctx.VDODO.options.address).call(),
|
||||
decimalStr("10")
|
||||
);
|
||||
assert.equal(
|
||||
await ctx.VDODO.methods.balanceOf(account0).call(),
|
||||
decimalStr("0.1")
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
await ctx.VDODO.methods.totalSupply().call(),
|
||||
decimalStr("0.1")
|
||||
);
|
||||
assert.notEqual(
|
||||
await ctx.VDODO.methods.lastRewardBlock().call(),
|
||||
ctx.lastRewardBlock
|
||||
);
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
@@ -47,6 +47,11 @@ export class VDODOContext {
|
||||
this.EVM = new EVM();
|
||||
this.Web3 = getDefaultWeb3();
|
||||
|
||||
const allAccounts = await this.Web3.eth.getAccounts();
|
||||
this.Deployer = allAccounts[0];
|
||||
this.Maintainer = allAccounts[1];
|
||||
this.SpareAccounts = allAccounts.slice(2, 10);
|
||||
|
||||
this.DODO = await contracts.newContract(
|
||||
contracts.MINTABLE_ERC20_CONTRACT_NAME,
|
||||
["DODO Token", "DODO", 18]
|
||||
@@ -67,9 +72,14 @@ export class VDODOContext {
|
||||
[this.DODOApprove.options.address]
|
||||
)
|
||||
|
||||
|
||||
this.Governance = await contracts.newContract(
|
||||
contracts.DODO_GOVERNANCE
|
||||
)
|
||||
this.VDODO = await contracts.newContract(
|
||||
contracts.VDODO_NAME,
|
||||
[
|
||||
this.Governance.options.address,
|
||||
this.DODO.options.address,
|
||||
this.DODOCirculationHelper.options.address,
|
||||
this.DODOApproveProxy.options.address,
|
||||
@@ -77,26 +87,31 @@ export class VDODOContext {
|
||||
]
|
||||
)
|
||||
|
||||
this.Governance = await contracts.newContract(
|
||||
contracts.DODO_GOVERNANCE,
|
||||
[this.VDODO.options.address]
|
||||
)
|
||||
await this.Governance.methods.initOwner(
|
||||
this.Deployer
|
||||
).send(this.sendParam(this.Deployer))
|
||||
|
||||
const allAccounts = await this.Web3.eth.getAccounts();
|
||||
this.Deployer = allAccounts[0];
|
||||
this.Maintainer = allAccounts[1];
|
||||
this.SpareAccounts = allAccounts.slice(2, 10);
|
||||
await this.Governance.methods.setVDODOAddress(
|
||||
this.VDODO.options.address
|
||||
).send(this.sendParam(this.Deployer))
|
||||
|
||||
await this.VDODO.methods.updateGovernance(
|
||||
this.Governance.options.address
|
||||
await this.DODOApprove.methods.init(this.Deployer,this.DODOApproveProxy.options.address).send(this.sendParam(this.Deployer));
|
||||
await this.DODOApproveProxy.methods.init(this.Deployer, [this.VDODO.options.address]).send(this.sendParam(this.Deployer));
|
||||
|
||||
|
||||
|
||||
|
||||
await this.VDODO.methods.initOwner(
|
||||
this.Deployer
|
||||
).send(this.sendParam(this.Deployer))
|
||||
|
||||
this.alpha = await this.VDODO.methods.alpha().call();
|
||||
this.lastRewardBlock = await this.VDODO.methods.lastRewardBlock().call();
|
||||
|
||||
console.log(log.blueText("[Init VDODO context]"));
|
||||
|
||||
console.log("alpha = "+ this.alpha);
|
||||
console.log("lastRewardBlock = " + this.lastRewardBlock);
|
||||
console.log(log.blueText("[Init VDODO context]"));
|
||||
}
|
||||
|
||||
sendParam(sender, value = "0") {
|
||||
@@ -111,6 +126,14 @@ export class VDODOContext {
|
||||
async mintTestToken(to: string, amount: string) {
|
||||
await this.DODO.methods.mint(to, amount).send(this.sendParam(this.Deployer));
|
||||
}
|
||||
async approveProxy(account: string) {
|
||||
await this.DODO.methods
|
||||
.approve(this.DODOApprove.options.address, MAX_UINT256)
|
||||
.send(this.sendParam(account));
|
||||
await this.VDODO.methods
|
||||
.approve(this.DODOApprove.options.address, MAX_UINT256)
|
||||
.send(this.sendParam(account));
|
||||
}
|
||||
}
|
||||
|
||||
export async function getVDODOContext(): Promise<VDODOContext> {
|
||||
|
||||
Reference in New Issue
Block a user