Updates tests after solium linting changes
This commit is contained in:
parent
bfa351c48d
commit
5e3c5ab0ac
|
@ -81,10 +81,10 @@ contract("DAppStore", function () {
|
|||
assert.strictEqual(available, parseInt(receipt.available, 10));
|
||||
|
||||
let votes_minted = Math.round((available/decimals) ** (decimals/rate));
|
||||
assert.strictEqual(votes_minted, parseInt(receipt.votes_minted, 10));
|
||||
assert.strictEqual(votes_minted, parseInt(receipt.votesMinted, 10));
|
||||
|
||||
assert.strictEqual(0, parseInt(receipt.votes_cast, 10));
|
||||
assert.strictEqual(amount, parseInt(receipt.effective_balance, 10));
|
||||
assert.strictEqual(0, parseInt(receipt.votesCast, 10));
|
||||
assert.strictEqual(amount, parseInt(receipt.effectiveBalance, 10));
|
||||
})
|
||||
|
||||
it("should not create a new DApp when exceeding the ceiling or staking nothing", async function () {
|
||||
|
@ -150,14 +150,14 @@ contract("DAppStore", function () {
|
|||
assert.strictEqual(available, parseInt(receipt.available, 10));
|
||||
|
||||
let votes_minted = Math.round((available/decimals) ** (decimals/rate));
|
||||
assert.strictEqual(votes_minted, parseInt(receipt.votes_minted, 10));
|
||||
assert.strictEqual(votes_minted, parseInt(receipt.votesMinted, 10));
|
||||
|
||||
// Only true for upvotes made when there are no downvotes
|
||||
assert.strictEqual(0, parseInt(receipt.votes_cast, 10));
|
||||
assert.strictEqual(0, parseInt(receipt.votesCast, 10));
|
||||
|
||||
// The effective_balance should match upvoteEffect + initial.effective_balance
|
||||
let e_balance = parseInt(up_effect, 10) + parseInt(initial.effective_balance, 10);
|
||||
assert.strictEqual(e_balance, parseInt(receipt.effective_balance, 10));
|
||||
// The effective_balance should match upvoteEffect + initial.effectiveBalance
|
||||
let e_balance = parseInt(up_effect, 10) + parseInt(initial.effectiveBalance, 10);
|
||||
assert.strictEqual(e_balance, parseInt(receipt.effectiveBalance, 10));
|
||||
})
|
||||
|
||||
it("should not let you upvote without spending SNT", async function () {
|
||||
|
@ -215,16 +215,16 @@ contract("DAppStore", function () {
|
|||
// Balance, rate, and votes_minted remain unchanged for downvotes
|
||||
assert.strictEqual(initial.balance, receipt.balance);
|
||||
assert.strictEqual(initial.rate, receipt.rate);
|
||||
assert.strictEqual(initial.votes_minted, receipt.votes_minted);
|
||||
assert.strictEqual(initial.votesMinted, receipt.votesMinted);
|
||||
|
||||
let available = parseInt(initial.available, 10) - parseInt(cost.c, 10);
|
||||
assert.strictEqual(available, parseInt(receipt.available, 10));
|
||||
|
||||
// This is only true for the first downvote
|
||||
assert.strictEqual(parseInt(receipt.votes_cast, 10), parseInt(cost.v_r, 10));
|
||||
assert.strictEqual(parseInt(receipt.votesCast, 10), parseInt(cost.v_r, 10));
|
||||
|
||||
let e_balance = parseInt(initial.effective_balance, 10) - parseInt(cost.b, 10);
|
||||
assert.strictEqual(e_balance, parseInt(receipt.effective_balance, 10));
|
||||
let e_balance = parseInt(initial.effectiveBalance, 10) - parseInt(cost.b, 10);
|
||||
assert.strictEqual(e_balance, parseInt(receipt.effectiveBalance, 10));
|
||||
})
|
||||
|
||||
it("should handle second downvote correctly", async function () {
|
||||
|
@ -253,16 +253,16 @@ contract("DAppStore", function () {
|
|||
// Balance, rate, and votes_minted remain unchanged for downvotes
|
||||
assert.strictEqual(initial.balance, receipt.balance);
|
||||
assert.strictEqual(initial.rate, receipt.rate);
|
||||
assert.strictEqual(initial.votes_minted, receipt.votes_minted);
|
||||
assert.strictEqual(initial.votesMinted, receipt.votesMinted);
|
||||
|
||||
let available = parseInt(initial.available, 10) - parseInt(cost.c, 10);
|
||||
assert.strictEqual(available, parseInt(receipt.available, 10));
|
||||
|
||||
let eff_v_cast = parseInt(receipt.votes_cast, 10) - parseInt(initial.votes_cast, 10);
|
||||
let eff_v_cast = parseInt(receipt.votesCast, 10) - parseInt(initial.votesCast, 10);
|
||||
assert.strictEqual(eff_v_cast, parseInt(cost.v_r, 10));
|
||||
|
||||
let e_balance = parseInt(initial.effective_balance, 10) - parseInt(cost.b, 10);
|
||||
assert.strictEqual(e_balance, parseInt(receipt.effective_balance, 10));
|
||||
let e_balance = parseInt(initial.effectiveBalance, 10) - parseInt(cost.b, 10);
|
||||
assert.strictEqual(e_balance, parseInt(receipt.effectiveBalance, 10));
|
||||
})
|
||||
|
||||
it("should not let you downvote by the wrong amount", async function () {
|
||||
|
@ -324,18 +324,18 @@ contract("DAppStore", function () {
|
|||
let available = upvotedBalance * rate;
|
||||
assert.strictEqual(available, parseInt(receipt.available, 10));
|
||||
|
||||
let votes_minted = parseInt(receipt.votes_minted, 10);
|
||||
let votes_minted = parseInt(receipt.votesMinted, 10);
|
||||
|
||||
// Votes have been cast by this stage, so we need to check how many there are
|
||||
// and confirm that `upvote` still calculates the effective_balance correctly
|
||||
let votes_cast = parseInt(receipt.votes_cast, 10);
|
||||
let votes_cast = parseInt(receipt.votesCast, 10);
|
||||
|
||||
let e_balance = Math.round(upvotedBalance - ((votes_cast*rate/decimals)*(available/decimals/votes_minted)));
|
||||
assert.strictEqual(e_balance, parseInt(receipt.effective_balance, 10));
|
||||
assert.strictEqual(e_balance, parseInt(receipt.effectiveBalance, 10));
|
||||
|
||||
// The effective_balance should also match upvoteEffect + initial.effective_balance
|
||||
let e_balance_2 = parseInt(up_effect, 10) + parseInt(initial.effective_balance, 10);
|
||||
assert.strictEqual(e_balance_2, parseInt(receipt.effective_balance, 10));
|
||||
// The effective_balance should also match upvoteEffect + initial.effectiveBalance
|
||||
let e_balance_2 = parseInt(up_effect, 10) + parseInt(initial.effectiveBalance, 10);
|
||||
assert.strictEqual(e_balance_2, parseInt(receipt.effectiveBalance, 10));
|
||||
})
|
||||
|
||||
it("should return correct upvoteEffect for use in UI", async function () {
|
||||
|
@ -357,9 +357,9 @@ contract("DAppStore", function () {
|
|||
|
||||
// Votes have been cast by this stage, so we need to check how many there are
|
||||
// and confirm that `upvoteEffect` mocks the effect correctly
|
||||
let votes_cast = parseInt(receipt.votes_cast, 10);
|
||||
let votes_cast = parseInt(receipt.votesCast, 10);
|
||||
let mEBalance = Math.round(mBalance - ((votes_cast*mRate/decimals)*(mAvailable/decimals/mVMinted)));
|
||||
let effect_calc = mEBalance - receipt.effective_balance;
|
||||
let effect_calc = mEBalance - receipt.effectiveBalance;
|
||||
|
||||
// Confirm that what is returned is (mEBalance - d.effective_balance)
|
||||
assert.strictEqual(effect_calc, parseInt(effect, 10));
|
||||
|
@ -406,7 +406,7 @@ contract("DAppStore", function () {
|
|||
let rate = Math.round(decimals - (balance * decimals/max));
|
||||
let available = Math.round(balance * rate);
|
||||
let v_minted = Math.round((available/decimals) ** (decimals/rate));
|
||||
let v_cast = parseInt(initial.votes_cast, 10);
|
||||
let v_cast = parseInt(initial.votesCast, 10);
|
||||
let e_balance = Math.ceil(balance - ((v_cast*rate/decimals)*(available/decimals/v_minted)));
|
||||
|
||||
let effective_balance = parseInt(receipt.newEffectiveBalance, 10);
|
||||
|
@ -423,7 +423,7 @@ contract("DAppStore", function () {
|
|||
|
||||
assert.strictEqual(parseInt(check.rate, 10), rate);
|
||||
assert.strictEqual(parseInt(check.available, 10), available);
|
||||
assert.strictEqual(parseInt(check.votes_minted, 10), v_minted);
|
||||
assert.strictEqual(parseInt(check.votesMinted, 10), v_minted);
|
||||
})
|
||||
|
||||
it("should not allow withdrawing more than was staked", async function () {
|
||||
|
@ -485,16 +485,16 @@ contract("DAppStore", function () {
|
|||
// Balance, rate, and votes_minted remain unchanged for downvotes
|
||||
assert.strictEqual(initial.balance, receipt.balance);
|
||||
assert.strictEqual(initial.rate, receipt.rate);
|
||||
assert.strictEqual(initial.votes_minted, receipt.votes_minted);
|
||||
assert.strictEqual(initial.votesMinted, receipt.votesMinted);
|
||||
|
||||
let available = parseInt(initial.available, 10) - parseInt(cost.c, 10);
|
||||
assert.strictEqual(available, parseInt(receipt.available, 10));
|
||||
|
||||
let eff_v_cast = parseInt(receipt.votes_cast, 10) - parseInt(initial.votes_cast, 10);
|
||||
let eff_v_cast = parseInt(receipt.votesCast, 10) - parseInt(initial.votesCast, 10);
|
||||
assert.strictEqual(eff_v_cast, parseInt(cost.v_r, 10));
|
||||
|
||||
let e_balance = parseInt(initial.effective_balance, 10) - parseInt(cost.b, 10);
|
||||
assert.strictEqual(e_balance, parseInt(receipt.effective_balance, 10));
|
||||
let e_balance = parseInt(initial.effectiveBalance, 10) - parseInt(cost.b, 10);
|
||||
assert.strictEqual(e_balance, parseInt(receipt.effectiveBalance, 10));
|
||||
})
|
||||
|
||||
it("should handle upvotes after withdrawals correctly", async function () {
|
||||
|
@ -532,17 +532,17 @@ contract("DAppStore", function () {
|
|||
let available = upvotedBalance * rate;
|
||||
assert.strictEqual(available, parseInt(receipt.available, 10));
|
||||
|
||||
let votes_minted = parseInt(receipt.votes_minted, 10);
|
||||
let votes_minted = parseInt(receipt.votesMinted, 10);
|
||||
|
||||
// Votes have been cast by this stage, so we need to check how many there are
|
||||
// and confirm that `upvote` still calculates the effective_balance correctly
|
||||
let votes_cast = parseInt(receipt.votes_cast, 10);
|
||||
let votes_cast = parseInt(receipt.votesCast, 10);
|
||||
|
||||
let e_balance = Math.ceil(upvotedBalance - ((votes_cast*rate/decimals)*(available/decimals/votes_minted)));
|
||||
assert.strictEqual(e_balance, parseInt(receipt.effective_balance, 10));
|
||||
assert.strictEqual(e_balance, parseInt(receipt.effectiveBalance, 10));
|
||||
|
||||
// The effective_balance should also match upvoteEffect + initial.effective_balance
|
||||
let e_balance_2 = parseInt(up_effect, 10) + parseInt(initial.effective_balance, 10);
|
||||
assert.strictEqual(e_balance_2, parseInt(receipt.effective_balance, 10));
|
||||
// The effective_balance should also match upvoteEffect + initial.effectiveBalance
|
||||
let e_balance_2 = parseInt(up_effect, 10) + parseInt(initial.effectiveBalance, 10);
|
||||
assert.strictEqual(e_balance_2, parseInt(receipt.effectiveBalance, 10));
|
||||
})
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue