@0x/contracts-staking: Fix stake accounting.

This commit is contained in:
Lawrence Forman
2019-09-25 15:29:22 -04:00
parent 9e3331d018
commit 5b77e2c8ac
4 changed files with 50 additions and 29 deletions

View File

@@ -39,7 +39,7 @@ blockchainTests.resets('Cumulative Reward Tracking', env => {
await simulation.runTestAsync(
[TestAction.Finalize],
[TestAction.CreatePool],
[{ event: 'SetCumulativeReward', epoch: 1 }, { event: 'SetMostRecentCumulativeReward', epoch: 1 }],
[{ event: 'SetCumulativeReward', epoch: 1 }],
);
});
it('delegating in the same epoch pool is created', async () => {
@@ -86,7 +86,7 @@ blockchainTests.resets('Cumulative Reward Tracking', env => {
// Unsets the CR for epoch 0
TestAction.Delegate,
],
[{ event: 'SetCumulativeReward', epoch: 1 }, { event: 'SetMostRecentCumulativeReward', epoch: 1 }],
[{ event: 'SetCumulativeReward', epoch: 1 }],
);
});
it('re-delegating in a new epoch', async () => {
@@ -105,7 +105,7 @@ blockchainTests.resets('Cumulative Reward Tracking', env => {
// Sets MRCR to epoch 1
TestAction.Delegate,
],
[{ event: 'SetCumulativeReward', epoch: 1 }, { event: 'SetMostRecentCumulativeReward', epoch: 1 }],
[{ event: 'SetCumulativeReward', epoch: 1 }],
);
});
it('delegating in epoch 1 then again in epoch 2', async () => {
@@ -128,7 +128,7 @@ blockchainTests.resets('Cumulative Reward Tracking', env => {
// Clears CR for epoch 1
TestAction.Delegate,
],
[{ event: 'SetCumulativeReward', epoch: 2 }, { event: 'SetMostRecentCumulativeReward', epoch: 2 }],
[{ event: 'SetCumulativeReward', epoch: 2 } ],
);
});
it('delegate in epoch 1 then undelegate in epoch 2', async () => {
@@ -152,7 +152,7 @@ blockchainTests.resets('Cumulative Reward Tracking', env => {
// Clear CR for epoch 1
TestAction.Undelegate,
],
[{ event: 'SetCumulativeReward', epoch: 2 }, { event: 'SetMostRecentCumulativeReward', epoch: 2 }],
[{ event: 'SetCumulativeReward', epoch: 2 } ],
);
});
it('delegate in epoch 0 and epoch 1, then undelegate half in epoch 2', async () => {
@@ -181,7 +181,7 @@ blockchainTests.resets('Cumulative Reward Tracking', env => {
// Clears CR for epoch 1
TestAction.Undelegate,
],
[{ event: 'SetCumulativeReward', epoch: 2 }, { event: 'SetMostRecentCumulativeReward', epoch: 2 }],
[{ event: 'SetCumulativeReward', epoch: 2 } ],
);
});
it('delegate in epoch 1 and 2 then again in 3', async () => {
@@ -210,7 +210,7 @@ blockchainTests.resets('Cumulative Reward Tracking', env => {
// Clears CR for epoch 1
TestAction.Delegate,
],
[{ event: 'SetCumulativeReward', epoch: 2 }, { event: 'SetMostRecentCumulativeReward', epoch: 2 }],
[{ event: 'SetCumulativeReward', epoch: 2 } ],
);
});
it('delegate in epoch 0, earn reward in epoch 1', async () => {
@@ -233,7 +233,7 @@ blockchainTests.resets('Cumulative Reward Tracking', env => {
// Sets MRCR to epoch 2
TestAction.Finalize,
],
[{ event: 'SetCumulativeReward', epoch: 2 }, { event: 'SetMostRecentCumulativeReward', epoch: 2 }],
[{ event: 'SetCumulativeReward', epoch: 2 } ],
);
});
it('delegate in epoch 0, epoch 2, earn reward in epoch 3, then delegate', async () => {
@@ -341,7 +341,7 @@ blockchainTests.resets('Cumulative Reward Tracking', env => {
// Clears CR for epoch 1
TestAction.Delegate,
],
[{ event: 'SetCumulativeReward', epoch: 4 }, { event: 'SetMostRecentCumulativeReward', epoch: 4 }],
[{ event: 'SetCumulativeReward', epoch: 4 } ],
);
});
it('earn reward in epoch 1 with no stake, then delegate', async () => {
@@ -362,7 +362,7 @@ blockchainTests.resets('Cumulative Reward Tracking', env => {
// Creates CR for epoch 2
TestAction.Delegate,
],
[{ event: 'SetCumulativeReward', epoch: 1 }, { event: 'SetMostRecentCumulativeReward', epoch: 1 }],
[{ event: 'SetCumulativeReward', epoch: 1 }],
);
});
it('delegate in epoch 1, 3, then delegate in epoch 4', async () => {
@@ -397,7 +397,7 @@ blockchainTests.resets('Cumulative Reward Tracking', env => {
// Creates CR for epoch 5
TestAction.Delegate,
],
[{ event: 'SetCumulativeReward', epoch: 4 }, { event: 'SetMostRecentCumulativeReward', epoch: 4 }],
[{ event: 'SetCumulativeReward', epoch: 4 } ],
);
});
it('delegate in epoch 1, then epoch 3', async () => {
@@ -425,7 +425,7 @@ blockchainTests.resets('Cumulative Reward Tracking', env => {
// Clears CR for epoch 2
TestAction.Delegate,
],
[{ event: 'SetCumulativeReward', epoch: 3 }, { event: 'SetMostRecentCumulativeReward', epoch: 3 }],
[{ event: 'SetCumulativeReward', epoch: 3 } ],
);
});
});