@@ -2,6 +2,7 @@ package prover
2
2
3
3
import (
4
4
"context"
5
+ "crypto/ecdsa"
5
6
"math/big"
6
7
"net/url"
7
8
"os"
@@ -42,57 +43,8 @@ func (s *ProverTestSuite) SetupTest() {
42
43
l1ProverPrivKey , err := crypto .ToECDSA (common .FromHex (os .Getenv ("L1_PROVER_PRIVATE_KEY" )))
43
44
s .Nil (err )
44
45
45
- proverServerURL := testutils .LocalRandomProverEndpoint ()
46
- port , err := strconv .Atoi (proverServerURL .Port ())
47
- s .Nil (err )
48
-
49
- decimal , err := s .RPCClient .TaikoToken .Decimals (nil )
50
- s .Nil (err )
51
-
52
- allowance := new (big.Int ).Exp (big .NewInt (1_000_000_100 ), new (big.Int ).SetUint64 (uint64 (decimal )), nil )
53
-
54
46
ctx , cancel := context .WithCancel (context .Background ())
55
- p := new (Prover )
56
- s .Nil (InitFromConfig (ctx , p , & Config {
57
- L1WsEndpoint : os .Getenv ("L1_NODE_WS_ENDPOINT" ),
58
- L1HttpEndpoint : os .Getenv ("L1_NODE_HTTP_ENDPOINT" ),
59
- L2WsEndpoint : os .Getenv ("L2_EXECUTION_ENGINE_WS_ENDPOINT" ),
60
- L2HttpEndpoint : os .Getenv ("L2_EXECUTION_ENGINE_HTTP_ENDPOINT" ),
61
- TaikoL1Address : common .HexToAddress (os .Getenv ("TAIKO_L1_ADDRESS" )),
62
- TaikoL2Address : common .HexToAddress (os .Getenv ("TAIKO_L2_ADDRESS" )),
63
- TaikoTokenAddress : common .HexToAddress (os .Getenv ("TAIKO_TOKEN_ADDRESS" )),
64
- AssignmentHookAddress : common .HexToAddress (os .Getenv ("ASSIGNMENT_HOOK_ADDRESS" )),
65
- GuardianProverAddress : common .HexToAddress (os .Getenv ("GUARDIAN_PROVER_CONTRACT_ADDRESS" )),
66
- L1ProverPrivKey : l1ProverPrivKey ,
67
- Dummy : true ,
68
- ProveUnassignedBlocks : true ,
69
- Capacity : 1024 ,
70
- MinOptimisticTierFee : common .Big1 ,
71
- MinSgxTierFee : common .Big1 ,
72
- MinPseZkevmTierFee : common .Big1 ,
73
- MinSgxAndPseZkevmTierFee : common .Big1 ,
74
- HTTPServerPort : uint64 (port ),
75
- WaitReceiptTimeout : 12 * time .Second ,
76
- DatabasePath : "" ,
77
- Allowance : allowance ,
78
- RPCTimeout : 3 * time .Second ,
79
- BackOffMaxRetrys : 3 ,
80
- }))
81
- p .srv = testutils .NewTestProverServer (
82
- & s .ClientTestSuite ,
83
- l1ProverPrivKey ,
84
- proverServerURL ,
85
- )
86
-
87
- p .guardianProverSender = guardianproversender .New (
88
- p .cfg .L1ProverPrivKey ,
89
- p .cfg .GuardianProverHealthCheckServerEndpoint ,
90
- memorydb .New (),
91
- p .rpc ,
92
- p .proverAddress ,
93
- )
94
-
95
- s .p = p
47
+ proverServerURL := s .initProver (ctx , l1ProverPrivKey )
96
48
s .cancel = cancel
97
49
98
50
// Init driver
@@ -280,6 +232,12 @@ func (s *ProverTestSuite) TestContestWrongBlocks() {
280
232
close (contestedSink )
281
233
}()
282
234
235
+ contesterKey , err := crypto .ToECDSA (common .FromHex (os .Getenv ("L1_CONTRACT_OWNER_PRIVATE_KEY" )))
236
+ s .Nil (err )
237
+
238
+ s .NotNil (s .initProver (context .Background (), contesterKey ))
239
+ s .p .cfg .ContesterMode = true
240
+
283
241
s .Greater (header .Number .Uint64 (), uint64 (0 ))
284
242
s .Nil (s .p .onTransitionProved (context .Background (), event ))
285
243
@@ -496,3 +454,58 @@ func (s *ProverTestSuite) TestSetApprovalAlreadySetHigher() {
496
454
func TestProverTestSuite (t * testing.T ) {
497
455
suite .Run (t , new (ProverTestSuite ))
498
456
}
457
+
458
+ func (s * ProverTestSuite ) initProver (ctx context.Context , key * ecdsa.PrivateKey ) * url.URL {
459
+ proverServerURL := testutils .LocalRandomProverEndpoint ()
460
+ port , err := strconv .Atoi (proverServerURL .Port ())
461
+ s .Nil (err )
462
+
463
+ decimal , err := s .RPCClient .TaikoToken .Decimals (nil )
464
+ s .Nil (err )
465
+
466
+ allowance := new (big.Int ).Exp (big .NewInt (1_000_000_100 ), new (big.Int ).SetUint64 (uint64 (decimal )), nil )
467
+
468
+ p := new (Prover )
469
+ s .Nil (InitFromConfig (ctx , p , & Config {
470
+ L1WsEndpoint : os .Getenv ("L1_NODE_WS_ENDPOINT" ),
471
+ L1HttpEndpoint : os .Getenv ("L1_NODE_HTTP_ENDPOINT" ),
472
+ L2WsEndpoint : os .Getenv ("L2_EXECUTION_ENGINE_WS_ENDPOINT" ),
473
+ L2HttpEndpoint : os .Getenv ("L2_EXECUTION_ENGINE_HTTP_ENDPOINT" ),
474
+ TaikoL1Address : common .HexToAddress (os .Getenv ("TAIKO_L1_ADDRESS" )),
475
+ TaikoL2Address : common .HexToAddress (os .Getenv ("TAIKO_L2_ADDRESS" )),
476
+ TaikoTokenAddress : common .HexToAddress (os .Getenv ("TAIKO_TOKEN_ADDRESS" )),
477
+ AssignmentHookAddress : common .HexToAddress (os .Getenv ("ASSIGNMENT_HOOK_ADDRESS" )),
478
+ GuardianProverAddress : common .HexToAddress (os .Getenv ("GUARDIAN_PROVER_CONTRACT_ADDRESS" )),
479
+ L1ProverPrivKey : key ,
480
+ Dummy : true ,
481
+ ProveUnassignedBlocks : true ,
482
+ Capacity : 1024 ,
483
+ MinOptimisticTierFee : common .Big1 ,
484
+ MinSgxTierFee : common .Big1 ,
485
+ MinPseZkevmTierFee : common .Big1 ,
486
+ MinSgxAndPseZkevmTierFee : common .Big1 ,
487
+ HTTPServerPort : uint64 (port ),
488
+ WaitReceiptTimeout : 12 * time .Second ,
489
+ DatabasePath : "" ,
490
+ Allowance : allowance ,
491
+ RPCTimeout : 3 * time .Second ,
492
+ BackOffMaxRetrys : 3 ,
493
+ }))
494
+ p .srv = testutils .NewTestProverServer (
495
+ & s .ClientTestSuite ,
496
+ key ,
497
+ proverServerURL ,
498
+ )
499
+
500
+ p .guardianProverSender = guardianproversender .New (
501
+ key ,
502
+ p .cfg .GuardianProverHealthCheckServerEndpoint ,
503
+ memorydb .New (),
504
+ p .rpc ,
505
+ p .proverAddress ,
506
+ )
507
+
508
+ s .p = p
509
+
510
+ return proverServerURL
511
+ }
0 commit comments