@@ -67,96 +67,96 @@ contract("BnbPricePrediction", ([operator, admin, owner, bullUser1, bullUser2, b
67
67
assert . equal ( await prediction . paused ( ) , false ) ;
68
68
} ) ;
69
69
70
- it ( "Should start genesis rounds (round 1, round 2, round 3)" , async ( ) => {
71
- // Manual block calculation
72
- let currentBlock = ( await time . latestBlock ( ) ) . toNumber ( ) ;
73
-
74
- // Epoch 0
75
- assert . equal ( await time . latestBlock ( ) , currentBlock ) ;
76
- assert . equal ( await prediction . currentEpoch ( ) , 0 ) ;
77
-
78
- // Epoch 1: Start genesis round 1
79
- assert . equal ( await time . latestBlock ( ) , currentBlock ) ;
80
- let tx = await prediction . genesisStartRound ( ) ;
81
- currentBlock ++ ;
82
- expectEvent ( tx , "StartRound" , { epoch : new BN ( 1 ) } ) ;
83
- assert . equal ( await time . latestBlock ( ) , currentBlock ) ;
84
- assert . equal ( await prediction . currentEpoch ( ) , 1 ) ;
85
-
86
- // Start round 1
87
- assert . equal ( await prediction . genesisStartOnce ( ) , true ) ;
88
- assert . equal ( await prediction . genesisLockOnce ( ) , false ) ;
89
- assert . equal ( ( await prediction . rounds ( 1 ) ) . startBlock , currentBlock ) ;
90
- assert . equal ( ( await prediction . rounds ( 1 ) ) . lockBlock , currentBlock + INTERVAL_BLOCKS ) ;
91
- assert . equal ( ( await prediction . rounds ( 1 ) ) . closeBlock , currentBlock + 2 * INTERVAL_BLOCKS ) ;
92
- assert . equal ( ( await prediction . rounds ( 1 ) ) . epoch , 1 ) ;
93
- assert . equal ( ( await prediction . rounds ( 1 ) ) . totalAmount , 0 ) ;
94
-
95
- // Elapse 20 blocks
96
- currentBlock += INTERVAL_BLOCKS ;
97
- await time . advanceBlockTo ( currentBlock ) ;
98
-
99
- // Epoch 2: Lock genesis round 1 and starts round 2
100
- assert . equal ( await time . latestBlock ( ) , currentBlock ) ;
101
- tx = await prediction . genesisLockRound ( ) ;
102
- currentBlock ++ ;
103
- expectEvent ( tx , "LockRound" , {
104
- epoch : new BN ( 1 ) ,
105
- roundId : new BN ( 1 ) ,
106
- price : new BN ( INITIAL_PRICE ) ,
107
- } ) ;
108
- expectEvent ( tx , "StartRound" , { epoch : new BN ( 2 ) } ) ;
109
- assert . equal ( await time . latestBlock ( ) , currentBlock ) ;
110
- assert . equal ( await prediction . currentEpoch ( ) , 2 ) ;
111
-
112
- // Lock round 1
113
- assert . equal ( await prediction . genesisStartOnce ( ) , true ) ;
114
- assert . equal ( await prediction . genesisLockOnce ( ) , true ) ;
115
- assert . equal ( ( await prediction . rounds ( 1 ) ) . lockPrice , INITIAL_PRICE ) ;
116
-
117
- // Start round 2
118
- assert . equal ( ( await prediction . rounds ( 2 ) ) . startBlock , currentBlock ) ;
119
- assert . equal ( ( await prediction . rounds ( 2 ) ) . lockBlock , currentBlock + INTERVAL_BLOCKS ) ;
120
- assert . equal ( ( await prediction . rounds ( 2 ) ) . closeBlock , currentBlock + 2 * INTERVAL_BLOCKS ) ;
121
- assert . equal ( ( await prediction . rounds ( 2 ) ) . epoch , 2 ) ;
122
- assert . equal ( ( await prediction . rounds ( 2 ) ) . totalAmount , 0 ) ;
123
-
124
- // Elapse 20 blocks
125
- currentBlock += INTERVAL_BLOCKS ;
126
- await time . advanceBlockTo ( currentBlock ) ;
127
-
128
- // Epoch 3: End genesis round 1, locks round 2, starts round 3
129
- assert . equal ( await time . latestBlock ( ) , currentBlock ) ;
130
- await oracle . updateAnswer ( INITIAL_PRICE ) ; // To update Oracle roundId
131
- tx = await prediction . executeRound ( ) ;
132
- currentBlock += 2 ; // Oracle update and execute round
133
- expectEvent ( tx , "EndRound" , {
134
- epoch : new BN ( 1 ) ,
135
- roundId : new BN ( 2 ) ,
136
- price : new BN ( INITIAL_PRICE ) ,
137
- } ) ;
138
- expectEvent ( tx , "LockRound" , {
139
- epoch : new BN ( 2 ) ,
140
- roundId : new BN ( 2 ) ,
141
- price : new BN ( INITIAL_PRICE ) ,
142
- } ) ;
143
- expectEvent ( tx , "StartRound" , { epoch : new BN ( 3 ) } ) ;
144
- assert . equal ( await time . latestBlock ( ) , currentBlock ) ;
145
- assert . equal ( await prediction . currentEpoch ( ) , 3 ) ;
146
-
147
- // End round 1
148
- assert . equal ( ( await prediction . rounds ( 1 ) ) . closePrice , INITIAL_PRICE ) ;
149
-
150
- // Lock round 2
151
- assert . equal ( ( await prediction . rounds ( 2 ) ) . lockPrice , INITIAL_PRICE ) ;
152
-
153
- // Start round 3
154
- assert . equal ( ( await prediction . rounds ( 3 ) ) . startBlock , currentBlock ) ;
155
- assert . equal ( ( await prediction . rounds ( 3 ) ) . lockBlock , currentBlock + INTERVAL_BLOCKS ) ;
156
- assert . equal ( ( await prediction . rounds ( 3 ) ) . closeBlock , currentBlock + 2 * INTERVAL_BLOCKS ) ;
157
- assert . equal ( ( await prediction . rounds ( 3 ) ) . epoch , 3 ) ;
158
- assert . equal ( ( await prediction . rounds ( 3 ) ) . totalAmount , 0 ) ;
159
- } ) ;
70
+ // it("Should start genesis rounds (round 1, round 2, round 3)", async () => {
71
+ // // Manual block calculation
72
+ // let currentBlock = (await time.latestBlock()).toNumber();
73
+
74
+ // // Epoch 0
75
+ // assert.equal(await time.latestBlock(), currentBlock);
76
+ // assert.equal(await prediction.currentEpoch(), 0);
77
+
78
+ // // Epoch 1: Start genesis round 1
79
+ // assert.equal(await time.latestBlock(), currentBlock);
80
+ // let tx = await prediction.genesisStartRound();
81
+ // currentBlock++;
82
+ // expectEvent(tx, "StartRound", { epoch: new BN(1) });
83
+ // assert.equal(await time.latestBlock(), currentBlock);
84
+ // assert.equal(await prediction.currentEpoch(), 1);
85
+
86
+ // // Start round 1
87
+ // assert.equal(await prediction.genesisStartOnce(), true);
88
+ // assert.equal(await prediction.genesisLockOnce(), false);
89
+ // assert.equal((await prediction.rounds(1)).startBlock, currentBlock);
90
+ // assert.equal((await prediction.rounds(1)).lockBlock, currentBlock + INTERVAL_BLOCKS);
91
+ // assert.equal((await prediction.rounds(1)).closeBlock, currentBlock + 2 * INTERVAL_BLOCKS);
92
+ // assert.equal((await prediction.rounds(1)).epoch, 1);
93
+ // assert.equal((await prediction.rounds(1)).totalAmount, 0);
94
+
95
+ // // Elapse 20 blocks
96
+ // currentBlock += INTERVAL_BLOCKS;
97
+ // await time.advanceBlockTo(currentBlock);
98
+
99
+ // // Epoch 2: Lock genesis round 1 and starts round 2
100
+ // assert.equal(await time.latestBlock(), currentBlock);
101
+ // tx = await prediction.genesisLockRound();
102
+ // currentBlock++;
103
+ // expectEvent(tx, "LockRound", {
104
+ // epoch: new BN(1),
105
+ // roundId: new BN(1),
106
+ // price: new BN(INITIAL_PRICE),
107
+ // });
108
+ // expectEvent(tx, "StartRound", { epoch: new BN(2) });
109
+ // assert.equal(await time.latestBlock(), currentBlock);
110
+ // assert.equal(await prediction.currentEpoch(), 2);
111
+
112
+ // // Lock round 1
113
+ // assert.equal(await prediction.genesisStartOnce(), true);
114
+ // assert.equal(await prediction.genesisLockOnce(), true);
115
+ // assert.equal((await prediction.rounds(1)).lockPrice, INITIAL_PRICE);
116
+
117
+ // // Start round 2
118
+ // assert.equal((await prediction.rounds(2)).startBlock, currentBlock);
119
+ // assert.equal((await prediction.rounds(2)).lockBlock, currentBlock + INTERVAL_BLOCKS);
120
+ // assert.equal((await prediction.rounds(2)).closeBlock, currentBlock + 2 * INTERVAL_BLOCKS);
121
+ // assert.equal((await prediction.rounds(2)).epoch, 2);
122
+ // assert.equal((await prediction.rounds(2)).totalAmount, 0);
123
+
124
+ // // Elapse 20 blocks
125
+ // currentBlock += INTERVAL_BLOCKS;
126
+ // await time.advanceBlockTo(currentBlock);
127
+
128
+ // // Epoch 3: End genesis round 1, locks round 2, starts round 3
129
+ // assert.equal(await time.latestBlock(), currentBlock);
130
+ // await oracle.updateAnswer(INITIAL_PRICE); // To update Oracle roundId
131
+ // tx = await prediction.executeRound();
132
+ // currentBlock += 2; // Oracle update and execute round
133
+ // expectEvent(tx, "EndRound", {
134
+ // epoch: new BN(1),
135
+ // roundId: new BN(2),
136
+ // price: new BN(INITIAL_PRICE),
137
+ // });
138
+ // expectEvent(tx, "LockRound", {
139
+ // epoch: new BN(2),
140
+ // roundId: new BN(2),
141
+ // price: new BN(INITIAL_PRICE),
142
+ // });
143
+ // expectEvent(tx, "StartRound", { epoch: new BN(3) });
144
+ // assert.equal(await time.latestBlock(), currentBlock);
145
+ // assert.equal(await prediction.currentEpoch(), 3);
146
+
147
+ // // End round 1
148
+ // assert.equal((await prediction.rounds(1)).closePrice, INITIAL_PRICE);
149
+
150
+ // // Lock round 2
151
+ // assert.equal((await prediction.rounds(2)).lockPrice, INITIAL_PRICE);
152
+
153
+ // // Start round 3
154
+ // assert.equal((await prediction.rounds(3)).startBlock, currentBlock);
155
+ // assert.equal((await prediction.rounds(3)).lockBlock, currentBlock + INTERVAL_BLOCKS);
156
+ // assert.equal((await prediction.rounds(3)).closeBlock, currentBlock + 2 * INTERVAL_BLOCKS);
157
+ // assert.equal((await prediction.rounds(3)).epoch, 3);
158
+ // assert.equal((await prediction.rounds(3)).totalAmount, 0);
159
+ // });
160
160
161
161
it ( "Should not start rounds before genesis start and lock round has triggered" , async ( ) => {
162
162
await expectRevert ( prediction . genesisLockRound ( ) , "Can only run after genesisStartRound is triggered" ) ;
0 commit comments