Commit 0d740f1a authored by Rob Myers's avatar Rob Myers

Final test updates for Staking Ratio.

parent 2537ab94
......@@ -11,21 +11,21 @@ contract('StakingRatio', function(accounts) {
it('should start with zero as A and B', async function() {
const instance = await StakingRatio.deployed();
const a = await instance.aAmount.call();
const a = await instance.totalAmountA.call();
assert.equal(a.toNumber(), 0);
const b = await instance.bAmount.call();
const b = await instance.totalAmountB.call();
assert.equal(b.toNumber(), 0);
});
it('should allow the user to stake both A and B', async function() {
const instance = await StakingRatio.deployed();
await instance.stakeA.sendTransaction({from: accounts[1], value: aAmount});
const a = await instance.aAmount.call();
const a = await instance.totalAmountA.call();
assert.ok(a.eq(aAmount));
const aStake = await instance.myAStake({ from: accounts[1] });
assert.ok(aStake.eq(aAmount));
await instance.stakeB.sendTransaction({from: accounts[1], value: bAmount});
const b = await instance.bAmount.call();
const b = await instance.totalAmountB.call();
assert.ok(b.eq(bAmount));
const bStake = await instance.myBStake({ from: accounts[1] });
assert.ok(bStake.eq(bAmount));
......@@ -34,12 +34,12 @@ contract('StakingRatio', function(accounts) {
it('should allow the user to stake A and B multiple times', async function() {
const instance = await StakingRatio.deployed();
await instance.stakeA.sendTransaction({from: accounts[1], value: aAmount});
const a = await instance.aAmount.call();
const a = await instance.totalAmountA.call();
assert.ok(a.eq(aAmount.mul(web3.utils.toBN(2))));
const aStake = await instance.myAStake({ from: accounts[1] });
assert.ok(aStake.eq(aAmount.mul(web3.utils.toBN(2))));
await instance.stakeB.sendTransaction({from: accounts[1], value: bAmount});
const b = await instance.bAmount.call();
const b = await instance.totalAmountB.call();
assert.ok(b.eq(bAmount.mul(web3.utils.toBN(2))));
const bStake = await instance.myBStake({ from: accounts[1] });
assert.ok(bStake.eq(bAmount.mul(web3.utils.toBN(2))));
......@@ -48,12 +48,12 @@ contract('StakingRatio', function(accounts) {
it('should allow multiple users to stake A and B', async function() {
const instance = await StakingRatio.deployed();
await instance.stakeA.sendTransaction({from: accounts[2], value: aAmount});
const a = await instance.aAmount.call();
const a = await instance.totalAmountA.call();
assert.ok(a.eq(aAmount.mul(web3.utils.toBN(3))));
const aStake = await instance.myAStake({ from: accounts[2] });
assert.ok(aStake.eq(aAmount));
await instance.stakeB.sendTransaction({from: accounts[2], value: bAmount});
const b = await instance.bAmount.call();
const b = await instance.totalAmountB.call();
assert.ok(b.eq(bAmount.mul(web3.utils.toBN(3))));
const bStake = await instance.myBStake({ from: accounts[2] });
assert.ok(bStake.eq(bAmount));
......@@ -62,12 +62,12 @@ contract('StakingRatio', function(accounts) {
it('should allow users with stake(s) to widthdraw', async function() {
const instance = await StakingRatio.deployed();
await instance.withdrawA.sendTransaction({from: accounts[1]});
const a = await instance.aAmount.call();
const a = await instance.totalAmountA.call();
assert.ok(a.eq(aAmount));
const aStake = await instance.myAStake({ from: accounts[1] });
assert.ok(aStake.eq(web3.utils.toBN(0)));
await instance.withdrawB.sendTransaction({from: accounts[1]});
const b = await instance.bAmount.call();
const b = await instance.totalAmountB.call();
assert.ok(b.eq(bAmount));
const bStake = await instance.myBStake({ from: accounts[1] });
assert.ok(bStake.eq(web3.utils.toBN(0)));
......@@ -76,16 +76,16 @@ contract('StakingRatio', function(accounts) {
it('should not allow users with no stake to widthdraw', async function() {
const instance = await StakingRatio.deployed();
await instance.withdrawA.sendTransaction({from: accounts[3]});
const a = await instance.aAmount.call();
const a = await instance.totalAmountA.call();
assert.ok(a.eq(aAmount));
});
it('should allow users to widthdraw all their stake(s)', async function() {
const instance = await StakingRatio.deployed();
await instance.withdrawAll.sendTransaction({from: accounts[2]});
const a = await instance.aAmount.call();
const a = await instance.totalAmountA.call();
assert.ok(a.eq(web3.utils.toBN(0)));
const b = await instance.bAmount.call();
const b = await instance.totalAmountB.call();
assert.ok(b.eq(web3.utils.toBN(0)));
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment