mirror of
https://github.com/status-im/discover-dapps.git
synced 2025-01-12 03:34:22 +00:00
Change downvote transfer so tests work
This commit is contained in:
parent
037805bacc
commit
d3b634e57e
@ -51,11 +51,11 @@ contract DAppStore is ApproveAndCallFallBack, BancorFormula {
|
|||||||
|
|
||||||
total = 3470483788;
|
total = 3470483788;
|
||||||
|
|
||||||
ceiling = 588; // 2 dec fixed pos, ie: 5 == 0.05, 588 == 5.88,
|
ceiling = 588; // See here for more: https://observablehq.com/@andytudhope/dapp-store-snt-curation-mechanism
|
||||||
|
|
||||||
decimals = 1000000;
|
decimals = 1000000; // 4 decimal points for %, 2 because we only use 1/100th of total in circulation
|
||||||
|
|
||||||
max = (total * ceiling) / decimals; // 4 decimal points for %, 2 because we only use 1/100th of total in circulation
|
max = (total * ceiling) / decimals;
|
||||||
|
|
||||||
safeMax = 98 * max / 100;
|
safeMax = 98 * max / 100;
|
||||||
}
|
}
|
||||||
@ -199,8 +199,9 @@ contract DAppStore is ApproveAndCallFallBack, BancorFormula {
|
|||||||
|
|
||||||
(uint b, uint v_r,) = downvoteCost(_id);
|
(uint b, uint v_r,) = downvoteCost(_id);
|
||||||
|
|
||||||
require(SNT.allowance(_from, d.developer) >= _amount, "Not enough SNT allowance");
|
require(SNT.allowance(_from, address(this)) >= _amount, "Not enough SNT allowance");
|
||||||
require(SNT.transferFrom(_from, d.developer, _amount), "Transfer failed");
|
require(SNT.transferFrom(_from, address(this), _amount), "Transfer failed");
|
||||||
|
require(SNT.transfer(d.developer, _amount), "Transfer failed");
|
||||||
|
|
||||||
d.available = d.available - _amount;
|
d.available = d.available - _amount;
|
||||||
d.votes_cast = d.votes_cast + v_r;
|
d.votes_cast = d.votes_cast + v_r;
|
||||||
|
@ -127,28 +127,28 @@ contract("DAppStore", function () {
|
|||||||
|
|
||||||
await SNT.methods.generateTokens(accounts[1], amount).send();
|
await SNT.methods.generateTokens(accounts[1], amount).send();
|
||||||
const encodedCall = DAppStore.methods.downvote(id,amount).encodeABI();
|
const encodedCall = DAppStore.methods.downvote(id,amount).encodeABI();
|
||||||
//await SNT.methods.approveAndCall(initial.developer, amount, encodedCall).send({from: accounts[1]});
|
await SNT.methods.approveAndCall(DAppStore.options.address, 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];
|
let developer = accounts[0];
|
||||||
// assert.strictEqual(receipt.developer, developer);
|
assert.strictEqual(receipt.developer, developer);
|
||||||
|
|
||||||
// assert.strictEqual(receipt.id, id);
|
assert.strictEqual(receipt.id, id);
|
||||||
|
|
||||||
// // Balance, rate, and votes_minted remain unchanged for downvotes
|
// Balance, rate, and votes_minted remain unchanged for downvotes
|
||||||
// assert.strictEqual(receipt.balance, initial.balance);
|
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);
|
let available = parseInt(initial.available, 10) - parseInt(cost.c, 10);
|
||||||
// assert.strictEqual(parseInt(receipt.available, 10), available);
|
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);
|
let e_balance = parseInt(initial.effective_balance, 10) - parseInt(cost.b, 10);
|
||||||
// assert.strictEqual(parseInt(receipt.effective_balance, 10), e_balance);
|
assert.strictEqual(parseInt(receipt.effective_balance, 10), e_balance);
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user