@@ -10,18 +10,18 @@ import (
10
10
11
11
"github.com/shutter-network/rolling-shutter/rolling-shutter/collator/batchhandler"
12
12
"github.com/shutter-network/rolling-shutter/rolling-shutter/db/cltrdb"
13
- "github.com/shutter-network/rolling-shutter/rolling-shutter/medley/epochid "
13
+ "github.com/shutter-network/rolling-shutter/rolling-shutter/medley/identitypreimage "
14
14
"github.com/shutter-network/rolling-shutter/rolling-shutter/p2pmsg"
15
15
)
16
16
17
17
func DefaultTestParams () TestParams {
18
18
return TestParams {
19
- GasLimit : uint64 (210000 ),
20
- BaseFee : big .NewInt (1 ),
21
- InitialBalance : big .NewInt (1000000 ),
22
- TxGasTipCap : big .NewInt (1 ),
23
- TxGasFeeCap : big .NewInt (2 ),
24
- InitialEpochID : epochid . Uint64ToEpochID (2000 ),
19
+ GasLimit : uint64 (210000 ),
20
+ BaseFee : big .NewInt (1 ),
21
+ InitialBalance : big .NewInt (1000000 ),
22
+ TxGasTipCap : big .NewInt (1 ),
23
+ TxGasFeeCap : big .NewInt (2 ),
24
+ InitialIdentityPreimage : identitypreimage . Uint64ToIdentityPreimage (2000 ),
25
25
}
26
26
}
27
27
@@ -32,7 +32,7 @@ func TestRejectBadTransactionsIntegration(t *testing.T) {
32
32
33
33
ctx := context .Background ()
34
34
fixtures := Setup (ctx , t , DefaultTestParams ())
35
- nextBatchIndex := int (fixtures .Params .InitialEpochID .Uint64 ())
35
+ nextBatchIndex := int (fixtures .Params .InitialIdentityPreimage .Uint64 ())
36
36
batchIndexAcceptenceInterval := int (fixtures .Config .BatchIndexAcceptenceInterval )
37
37
t .Run ("Future" , func (t * testing.T ) {
38
38
tx , _ := fixtures .MakeTx (t , 0 , nextBatchIndex + batchIndexAcceptenceInterval , 0 , 22000 )
@@ -72,7 +72,7 @@ func TestRejectTxNotEnoughFundsIntegration(t *testing.T) {
72
72
73
73
ctx := context .Background ()
74
74
fixtures := Setup (ctx , t , DefaultTestParams ())
75
- nextBatchIndex := int (fixtures .Params .InitialEpochID .Uint64 ())
75
+ nextBatchIndex := int (fixtures .Params .InitialIdentityPreimage .Uint64 ())
76
76
tx , _ := fixtures .MakeTx (t , 1 , nextBatchIndex , 0 , 22000 )
77
77
err := fixtures .Batcher .EnqueueTx (ctx , tx )
78
78
assert .Error (t , err , ErrCannotPayGasFee .Error ())
@@ -85,15 +85,15 @@ func TestConfirmTransactionsIntegration(t *testing.T) {
85
85
86
86
ctx := context .Background ()
87
87
fixtures := Setup (ctx , t , DefaultTestParams ())
88
- nextBatchIndex := int (fixtures .Params .InitialEpochID .Uint64 ())
88
+ nextBatchIndex := int (fixtures .Params .InitialIdentityPreimage .Uint64 ())
89
89
90
90
for nonce := 0 ; nonce < 5 ; nonce ++ {
91
91
tx , _ := fixtures .MakeTx (t , 0 , nextBatchIndex , nonce , 22000 )
92
92
err := fixtures .Batcher .EnqueueTx (ctx , tx )
93
93
assert .NilError (t , err )
94
94
}
95
95
96
- txs , err := fixtures .DB .GetTransactionsByEpoch (ctx , fixtures .Params .InitialEpochID .Bytes ())
96
+ txs , err := fixtures .DB .GetTransactionsByEpoch (ctx , fixtures .Params .InitialIdentityPreimage .Bytes ())
97
97
assert .NilError (t , err )
98
98
assert .Equal (t , 5 , len (txs ), "should have exactly one tx: %+v" , txs )
99
99
for nonce := 0 ; nonce < 5 ; nonce ++ {
@@ -120,7 +120,7 @@ func TestCloseBatchIntegration(t *testing.T) {
120
120
assert .Check (t , fixtures .Batcher .nextBatchChainState == nil , "nextBatchChainState field initialized" )
121
121
nextBatchEpoch , _ , err := batchhandler .GetNextBatch (ctx , fixtures .DB )
122
122
assert .NilError (t , err )
123
- assert .Equal (t , nextBatchEpoch .Uint64 (), fixtures .Params .InitialEpochID .Uint64 ()+ 1 )
123
+ assert .Equal (t , nextBatchEpoch .Uint64 (), fixtures .Params .InitialIdentityPreimage .Uint64 ()+ 1 )
124
124
})
125
125
126
126
t .Run ("initChainStateWaitForSequencer" , func (t * testing.T ) {
@@ -129,13 +129,13 @@ func TestCloseBatchIntegration(t *testing.T) {
129
129
})
130
130
131
131
t .Run ("batchAlreadyExists" , func (t * testing.T ) {
132
- fixtures .EthL2Server .SetBatchIndex (fixtures .Params .InitialEpochID .Uint64 () + 1 )
132
+ fixtures .EthL2Server .SetBatchIndex (fixtures .Params .InitialIdentityPreimage .Uint64 () + 1 )
133
133
err = fixtures .Batcher .initChainState (ctx )
134
134
assert .Error (t , err , ErrBatchAlreadyExists .Error ())
135
135
})
136
136
137
137
t .Run ("initChainStateSetsNextBatchChainState" , func (t * testing.T ) {
138
- fixtures .EthL2Server .SetBatchIndex (fixtures .Params .InitialEpochID .Uint64 ())
138
+ fixtures .EthL2Server .SetBatchIndex (fixtures .Params .InitialIdentityPreimage .Uint64 ())
139
139
err = fixtures .Batcher .initChainState (ctx )
140
140
assert .NilError (t , err )
141
141
assert .Check (t , fixtures .Batcher .nextBatchChainState != nil , "nextBatchChainState field not initialized" )
@@ -160,7 +160,7 @@ func TestOpenNextBatch(t *testing.T) {
160
160
assert .NilError (t , err )
161
161
nextBatchIndex := nextBatchEpoch .Uint64 ()
162
162
163
- assert .Equal (t , nextBatchIndex , fixtures .Params .InitialEpochID .Uint64 ()+ 1 )
163
+ assert .Equal (t , nextBatchIndex , fixtures .Params .InitialIdentityPreimage .Uint64 ()+ 1 )
164
164
// we should now be able to enqueue transactions. The batcher however doesn't have
165
165
// information about the current nonce and the balances, so we're able to enqueue
166
166
// transactions that later will be rejected when the l2 chain builds a new block.
@@ -174,20 +174,20 @@ func TestOpenNextBatch(t *testing.T) {
174
174
err = fixtures .Batcher .EnqueueTx (ctx , tx2 )
175
175
assert .NilError (t , err )
176
176
177
- txs , err := fixtures .DB .GetNonRejectedTransactionsByEpoch (ctx , epochid . Uint64ToEpochID (nextBatchIndex ).Bytes ())
177
+ txs , err := fixtures .DB .GetNonRejectedTransactionsByEpoch (ctx , identitypreimage . Uint64ToIdentityPreimage (nextBatchIndex ).Bytes ())
178
178
assert .NilError (t , err )
179
179
assert .Equal (t , len (txs ), 2 )
180
180
181
181
// so, now let's let the l2 chain build a new block
182
- fixtures .EthL2Server .SetBatchIndex (fixtures .Params .InitialEpochID .Uint64 ())
182
+ fixtures .EthL2Server .SetBatchIndex (fixtures .Params .InitialIdentityPreimage .Uint64 ())
183
183
184
184
tx3 , _ := fixtures .MakeTx (t , 2 , int (nextBatchIndex ), 0 , 22000 )
185
185
err = fixtures .Batcher .EnqueueTx (ctx , tx3 )
186
186
assert .Error (t , err , ErrCannotPayGasFee .Error ())
187
187
188
188
assert .Check (t , fixtures .Batcher .nextBatchChainState != nil , "nextBatchChainState field not initialized" )
189
189
190
- txs , err = fixtures .DB .GetTransactionsByEpoch (ctx , epochid . Uint64ToEpochID (nextBatchIndex ).Bytes ())
190
+ txs , err = fixtures .DB .GetTransactionsByEpoch (ctx , identitypreimage . Uint64ToIdentityPreimage (nextBatchIndex ).Bytes ())
191
191
assert .NilError (t , err )
192
192
assert .Equal (t , len (txs ), 2 )
193
193
@@ -210,7 +210,7 @@ func TestDecryptionTriggerGeneratedIntegration(t *testing.T) {
210
210
assert .NilError (t , err )
211
211
nextBatchIndex := nextBatchEpoch .Uint64 ()
212
212
213
- assert .Equal (t , nextBatchIndex , fixtures .Params .InitialEpochID .Uint64 ())
213
+ assert .Equal (t , nextBatchIndex , fixtures .Params .InitialIdentityPreimage .Uint64 ())
214
214
215
215
tx , txHash := fixtures .MakeTx (t , 0 , int (nextBatchIndex ), 0 , 22000 )
216
216
err = fixtures .Batcher .EnqueueTx (ctx , tx )
@@ -247,13 +247,13 @@ func TestDecryptionTriggerInsertOrderingIntegration(t *testing.T) {
247
247
fixtures := Setup (ctx , t , DefaultTestParams ())
248
248
249
249
trigger1 := cltrdb.InsertTriggerParams {
250
- EpochID : epochid . Uint64ToEpochID (2 ).Bytes (),
250
+ EpochID : identitypreimage . Uint64ToIdentityPreimage (2 ).Bytes (),
251
251
BatchHash : common .BytesToHash ([]byte {1 , 0 }).Bytes (),
252
252
L1BlockNumber : 666 ,
253
253
}
254
254
255
255
trigger2 := cltrdb.InsertTriggerParams {
256
- EpochID : epochid . Uint64ToEpochID (1 ).Bytes (),
256
+ EpochID : identitypreimage . Uint64ToIdentityPreimage (1 ).Bytes (),
257
257
BatchHash : common .BytesToHash ([]byte {0 , 1 }).Bytes (),
258
258
L1BlockNumber : 42 ,
259
259
}
0 commit comments