More tests, WIP

This commit is contained in:
Andy Tudhope 2019-04-08 22:11:06 +02:00
parent 73400ff3ac
commit 4a2e3f8f6e
No known key found for this signature in database
GPG Key ID: 02A3DFA93BF26AD2
1 changed files with 15 additions and 15 deletions

View File

@ -53,7 +53,7 @@ contract("DAppStore", function () {
it("should create a new DApp and initialise it correctly", async function () {
let id = "0x7465737400000000000000000000000000000000000000000000000000000000";
let amount = 10000;
let amount = 100000;
await SNT.methods.generateTokens(accounts[0], amount).send();
const encodedCall = DAppStore.methods.createDApp(id,amount).encodeABI();
@ -125,31 +125,31 @@ contract("DAppStore", function () {
let initial = await DAppStore.methods.dapps(0).call();
await SNT.methods.generateTokens(accounts[1], 10000).send();
await SNT.methods.generateTokens(accounts[1], amount).send();
const encodedCall = DAppStore.methods.downvote(id,amount).encodeABI();
console.log(initial.developer, amount);
await SNT.methods.approveAndCall(initial.developer, amount, encodedCall).send({from: accounts[1]});
let receipt = await DAppStore.methods.dapps(0).call();
// let receipt = await DAppStore.methods.dapps(0).call();
let developer = accounts[0];
assert.strictEqual(receipt.developer, developer);
// let developer = accounts[0];
// assert.strictEqual(receipt.developer, developer);
assert.strictEqual(receipt.id, id);
// assert.strictEqual(receipt.id, id);
// Balance, rate, and votes_minted remain unchanged for downvotes
assert.strictEqual(receipt.balance, initial.balance);
// // Balance, rate, and votes_minted remain unchanged for downvotes
// assert.strictEqual(receipt.balance, initial.balance);
assert.strictEqual(receipt.rate, initial.rate);
// assert.strictEqual(receipt.rate, initial.rate);
assert.strictEqual(receipt.votes_minted, initial.votes_minted);
// assert.strictEqual(receipt.votes_minted, initial.votes_minted);
let available = parseInt(initial.available, 10) - parseInt(cost.c, 10);
assert.strictEqual(parseInt(receipt.available, 10), available);
// let available = parseInt(initial.available, 10) - parseInt(cost.c, 10);
// assert.strictEqual(parseInt(receipt.available, 10), available);
assert.strictEqual(parseInt(receipt.votes_cast, 10), parseInt(cost.v_r, 10));
// assert.strictEqual(parseInt(receipt.votes_cast, 10), parseInt(cost.v_r, 10));
let e_balance = parseInt(initial.effective_balance, 10) - parseInt(cost.b, 10);
assert.strictEqual(parseInt(receipt.effective_balance, 10), e_balance);
// let e_balance = parseInt(initial.effective_balance, 10) - parseInt(cost.b, 10);
// assert.strictEqual(parseInt(receipt.effective_balance, 10), e_balance);
})
});