Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix tests #1733

Merged
merged 4 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions aggregator/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ func (a *Aggregator) Channel(stream pb.AggregatorService_ChannelServer) error {

// Check if prover supports the required Fork ID
if !prover.SupportsForkID(a.cfg.ForkId) {
log.Warn("Prover does not support required fork ID.")
return errors.New("prover does not support required fork ID")
log.Warnf("Prover does not support required fork ID: %d.", a.cfg.ForkId)
return fmt.Errorf("prover does not support required fork ID: %d", a.cfg.ForkId)
}

for {
Expand Down
2 changes: 1 addition & 1 deletion aggregator/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ type Config struct {
ChainID uint64

// ForkID is the L2 ForkID provided by the Network Config
ForkId uint64
ForkId uint64 `mapstructure:"ForkId"`

// SenderAddress defines which private key the eth tx manager needs to use
// to sign the L1 txs
Expand Down
3 changes: 2 additions & 1 deletion config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ DefaultSenderAddress = "0x1111111111111111111111111111111111111111"
[Synchronizer]
SyncInterval = "0s"
SyncChunkSize = 100
GenBlockNumber = 66
GenBlockNumber = 67

[Sequencer]
WaitPeriodPoolIsEmpty = "1s"
Expand Down Expand Up @@ -109,6 +109,7 @@ DefaultPrice = "2000"
[Aggregator]
Host = "0.0.0.0"
Port = 50081
ForkId = 2
RetryTime = "5s"
VerifyProofInterval = "90s"
TxProfitabilityCheckerType = "acceptall"
Expand Down
3 changes: 2 additions & 1 deletion config/environments/local/local.node.config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ DefaultSenderAddress = "0x1111111111111111111111111111111111111111"
[Synchronizer]
SyncInterval = "1s"
SyncChunkSize = 100
GenBlockNumber = 66
GenBlockNumber = 67

[Sequencer]
WaitPeriodPoolIsEmpty = "1s"
Expand Down Expand Up @@ -96,6 +96,7 @@ MaxAllowedFailedCounter = 50
[Aggregator]
Host = "0.0.0.0"
Port = 50081
ForkId = 2
RetryTime = "5s"
VerifyProofInterval = "30s"
TxProfitabilityCheckerType = "acceptall"
Expand Down
28 changes: 15 additions & 13 deletions sequencer/finalizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func TestFinalizer_syncWithState(t *testing.T) {
getWIPBatchErr error
openBatchErr error
isBatchClosedErr error
getLastBatchNumErr error
getLastBatchErr error
expectedProcessingCtx state.ProcessingContext
expectedBatch *WipBatch
expectedErr error
Expand Down Expand Up @@ -330,6 +330,7 @@ func TestFinalizer_syncWithState(t *testing.T) {
name: "Success-Open Batch",
lastBatchNum: &one,
isBatchClosed: false,
batches: batches,
ger: common.Hash{},
expectedBatch: &WipBatch{
batchNumber: one,
Expand All @@ -348,13 +349,13 @@ func TestFinalizer_syncWithState(t *testing.T) {
},
},
{
name: "Error-Failed to get last batch number",
lastBatchNum: nil,
batches: batches,
isBatchClosed: true,
ger: oldHash,
getLastBatchNumErr: testErr,
expectedErr: fmt.Errorf("failed to get last batch number, err: %w", testErr),
name: "Error-Failed to get last batch",
lastBatchNum: nil,
batches: batches,
isBatchClosed: true,
ger: oldHash,
getLastBatchErr: testErr,
expectedErr: fmt.Errorf("failed to get last batch, err: %w", testErr),
},
{
name: "Error-Failed to check if batch is closed",
Expand Down Expand Up @@ -395,20 +396,21 @@ func TestFinalizer_syncWithState(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
// arrange
if tc.lastBatchNum == nil {
dbManagerMock.Mock.On("GetLastBatchNumber", ctx).Return(one, tc.getLastBatchNumErr).Once()
dbManagerMock.Mock.On("GetLastBatch", ctx).Return(tc.batches[0], tc.getLastBatchErr).Once()
} else {
dbManagerMock.On("GetBatchByNumber", ctx, *tc.lastBatchNum, nil).Return(tc.batches[0], nilErr).Once()
}

if tc.getLastBatchNumErr == nil {
if tc.getLastBatchErr == nil {
dbManagerMock.Mock.On("IsBatchClosed", ctx, *tc.lastBatchNum).Return(tc.isBatchClosed, tc.isBatchClosedErr).Once()
}

if tc.isBatchClosed {
if tc.getLastBatchNumErr == nil && tc.isBatchClosedErr == nil {
dbManagerMock.On("GetLastNBatches", ctx, uint(2)).Return(tc.batches, nilErr).Once()
if tc.getLastBatchErr == nil && tc.isBatchClosedErr == nil {
dbManagerMock.On("OpenBatch", ctx, tc.expectedProcessingCtx, dbTxMock).Return(tc.openBatchErr).Once()
}

if tc.getLastBatchNumErr == nil && tc.isBatchClosedErr == nil {
if tc.getLastBatchErr == nil && tc.isBatchClosedErr == nil {
dbManagerMock.Mock.On("GetLatestGer", ctx, f.cfg.GERFinalityNumberOfBlocks).Return(state.GlobalExitRoot{GlobalExitRoot: tc.ger}, testNow(), nil).Once()
dbManagerMock.On("BeginStateTransaction", ctx).Return(dbTxMock, nil).Once()
if tc.openBatchErr == nil {
Expand Down
3 changes: 2 additions & 1 deletion test/config/debug.node.config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ DefaultSenderAddress = "0x1111111111111111111111111111111111111111"
[Synchronizer]
SyncInterval = "5s"
SyncChunkSize = 100
GenBlockNumber = 66
GenBlockNumber = 67

[Sequencer]
WaitPeriodPoolIsEmpty = "1s"
Expand Down Expand Up @@ -96,6 +96,7 @@ MaxAllowedFailedCounter = 50
[Aggregator]
Host = "0.0.0.0"
Port = 50081
ForkId = 2
RetryTime = "5s"
VerifyProofInterval = "30s"
TxProfitabilityCheckerType = "acceptall"
Expand Down
3 changes: 2 additions & 1 deletion test/config/test.node.config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ DefaultSenderAddress = "0x1111111111111111111111111111111111111111"
[Synchronizer]
SyncInterval = "1s"
SyncChunkSize = 100
GenBlockNumber = 66
GenBlockNumber = 67

[Sequencer]
WaitPeriodPoolIsEmpty = "1s"
Expand Down Expand Up @@ -96,6 +96,7 @@ MaxAllowedFailedCounter = 50
[Aggregator]
Host = "0.0.0.0"
Port = 50081
ForkId = 2
RetryTime = "5s"
VerifyProofInterval = "30s"
TxProfitabilityCheckerType = "acceptall"
Expand Down
2 changes: 1 addition & 1 deletion test/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ services:

zkevm-mock-l1-network:
container_name: zkevm-mock-l1-network
image: hermeznetwork/geth-zkevm-contracts:test
image: hermeznetwork/geth-zkevm-contracts:test-fork
ports:
- 8545:8545
- 8546:8546
Expand Down
2 changes: 1 addition & 1 deletion tools/executor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func runTestCase(ctx context.Context, genesis []genesisItem, tc testCase) error
log.Infof("CntBinaries: %v", res.CntBinaries)
log.Infof("CntSteps: %v", res.CntSteps)
for i, txRes := range res.Responses {
log.Infof("======> TX #%d", i)
log.Infof("=====> TX #%d", i)
if "0x"+hex.EncodeToString(txRes.TxHash) != txs[i].Hash().Hex() {
log.Warnf("TxHash missmatch:\nexecutor: %s\ndecoded: %s", "0x"+hex.EncodeToString(txRes.TxHash), txs[i].Hash().Hex())
} else {
Expand Down