Skip to content

Commit

Permalink
test: abstract some mining heights
Browse files Browse the repository at this point in the history
It is much more useful to mine based
on the auction lengths instead of using
magic numbers. This allows the parameters
to be tweaked and then ran through the
test suite because it is possible to choose
parameters that do not allow the auctions
to work at all. The `Network.get` call
at the top of the file can be altered
to select a different network, such as
simnet.
  • Loading branch information
Mark Tyneway authored and nodech committed Oct 18, 2023
1 parent 5c287c9 commit 9df28c2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 31 deletions.
34 changes: 17 additions & 17 deletions test/auction-reorg-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ describe('Auction Reorg', function() {
assert(await chain.add(block));
});

it('should mine 10 blocks', async () => {
for (let i = 0; i < 10; i++) {
it('should mine through the bidding period', async () => {
for (let i = 0; i < network.names.biddingPeriod; i++) {
const block = await cpu.mineBlock();
assert(block);
assert(await chain.add(block));
Expand All @@ -161,8 +161,8 @@ describe('Auction Reorg', function() {
assert(await chain.add(block));
});

it('should mine 20 blocks', async () => {
for (let i = 0; i < 20; i++) {
it('should mine through the reveal period', async () => {
for (let i = 0; i < network.names.revealPeriod; i++) {
const block = await cpu.mineBlock();
assert(block);
assert(await chain.add(block));
Expand All @@ -186,14 +186,6 @@ describe('Auction Reorg', function() {
assert(await chain.add(block));
});

it('should mine 10 blocks', async () => {
for (let i = 0; i < 10; i++) {
const block = await cpu.mineBlock();
assert(block);
assert(await chain.add(block));
}
});

it('should register again and update tree', async () => {
const mtx = await winner.createUpdate(NAME1, Buffer.from([1,2,4]));

Expand All @@ -218,6 +210,14 @@ describe('Auction Reorg', function() {
assert(await chain.add(block));
});

it('should mine past tree interval', async () => {
for (let i = 0; i < network.names.treeInterval; i++) {
const block = await cpu.mineBlock();
assert(block);
assert(await chain.add(block));
}
});

it('should renew', async () => {
const mtx = await winner.createRenewal(NAME1);

Expand Down Expand Up @@ -251,7 +251,7 @@ describe('Auction Reorg', function() {
assert.strictEqual(err.reason, 'bad-renewal-premature');
});

it('should mine 10 blocks', async () => {
it('should mine through tree txn commitment', async () => {
const left = treeInterval - (chain.height % treeInterval);

for (let i = 0; i < left; i++) {
Expand Down Expand Up @@ -546,8 +546,8 @@ describe('Auction Reorg', function() {
});
*/

it('should mine 20 blocks', async () => {
for (let i = 0; i < 20; i++) {
it('should mine a tree interval blocks', async () => {
for (let i = 0; i < network.names.treeInterval; i++) {
const block = await cpu.mineBlock();
assert(block);
assert(await chain.add(block));
Expand Down Expand Up @@ -620,8 +620,8 @@ describe('Auction Reorg', function() {
assert.strictEqual(err.reason, 'bad-finalize-maturity');
});

it('should mine 20 blocks', async () => {
for (let i = 0; i < 20; i++) {
it('should mine through the transfer lock period', async () => {
for (let i = 0; i < network.names.transferLockup; i++) {
const block = await cpu.mineBlock();
assert(block);
assert(await chain.add(block));
Expand Down
28 changes: 14 additions & 14 deletions test/auction-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ describe('Auction', function() {
assert(await chain.add(block));
});

it('should mine 10 blocks', async () => {
for (let i = 0; i < 10; i++) {
it('should mine through the bidding period', async () => {
for (let i = 0; i < network.names.biddingPeriod; i++) {
const block = await cpu.mineBlock();
assert(block);
assert(await chain.add(block));
Expand All @@ -159,8 +159,8 @@ describe('Auction', function() {
assert(await chain.add(block));
});

it('should mine 20 blocks', async () => {
for (let i = 0; i < 20; i++) {
it('should mine through the reveal period', async () => {
for (let i = 0; i < network.names.revealPeriod; i++) {
const block = await cpu.mineBlock();
assert(block);
assert(await chain.add(block));
Expand All @@ -184,8 +184,8 @@ describe('Auction', function() {
assert(await chain.add(block));
});

it('should mine 10 blocks', async () => {
for (let i = 0; i < 10; i++) {
it('should mine a tree interval', async () => {
for (let i = 0; i < network.names.treeInterval; i++) {
const block = await cpu.mineBlock();
assert(block);
assert(await chain.add(block));
Expand Down Expand Up @@ -249,8 +249,8 @@ describe('Auction', function() {
assert.strictEqual(err.reason, 'bad-renewal-premature');
});

it('should mine 10 blocks', async () => {
for (let i = 0; i < 10; i++) {
it('should mine a tree interval', async () => {
for (let i = 0; i < network.names.treeInterval; i++) {
const block = await cpu.mineBlock();
assert(block);
assert(await chain.add(block));
Expand Down Expand Up @@ -500,8 +500,8 @@ describe('Auction', function() {
miner.addAddress(wallet.getReceive());
});

it('should mine 20 blocks', async () => {
for (let i = 0; i < 20; i++) {
it('should mine a tree interval', async () => {
for (let i = 0; i < network.names.treeInterval; i++) {
const block = await cpu.mineBlock();
assert(block);
assert(await chain.add(block));
Expand Down Expand Up @@ -725,8 +725,8 @@ describe('Auction', function() {
});
*/

it('should mine 20 blocks', async () => {
for (let i = 0; i < 20; i++) {
it('should mine a tree interval', async () => {
for (let i = 0; i < network.names.treeInterval; i++) {
const block = await cpu.mineBlock();
assert(block);
assert(await chain.add(block));
Expand Down Expand Up @@ -799,8 +799,8 @@ describe('Auction', function() {
assert.strictEqual(err.reason, 'bad-finalize-maturity');
});

it('should mine 20 blocks', async () => {
for (let i = 0; i < 20; i++) {
it('should mine through the transfer lockup period', async () => {
for (let i = 0; i < network.names.transferLockup; i++) {
const block = await cpu.mineBlock();
assert(block);
assert(await chain.add(block));
Expand Down

0 comments on commit 9df28c2

Please sign in to comment.