forked from scroll-tech/scroll
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
random container port (scroll-tech#47)
Co-authored-by: colinlyguo <[email protected]> Co-authored-by: HAOYUatHZ <[email protected]>
- Loading branch information
1 parent
a648073
commit defe1f4
Showing
30 changed files
with
727 additions
and
980 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.idea | ||
assets/params* | ||
assets/seed | ||
coverage.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package l2_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/scroll-tech/go-ethereum/ethclient" | ||
"github.com/stretchr/testify/assert" | ||
|
||
"scroll-tech/common/docker" | ||
|
||
"scroll-tech/bridge/config" | ||
) | ||
|
||
var ( | ||
// config | ||
cfg *config.Config | ||
|
||
// docker consider handler. | ||
l1gethImg docker.ImgInstance | ||
l2gethImg docker.ImgInstance | ||
dbImg docker.ImgInstance | ||
|
||
// l2geth client | ||
l2Cli *ethclient.Client | ||
) | ||
|
||
func setupEnv(t *testing.T) (err error) { | ||
// Load config. | ||
cfg, err = config.NewConfig("../config.json") | ||
assert.NoError(t, err) | ||
|
||
// Create l1geth container. | ||
l1gethImg = docker.NewTestL1Docker(t) | ||
cfg.L2Config.RelayerConfig.SenderConfig.Endpoint = l1gethImg.Endpoint() | ||
cfg.L1Config.Endpoint = l1gethImg.Endpoint() | ||
|
||
// Create l2geth container. | ||
l2gethImg = docker.NewTestL2Docker(t) | ||
cfg.L1Config.RelayerConfig.SenderConfig.Endpoint = l2gethImg.Endpoint() | ||
cfg.L2Config.Endpoint = l2gethImg.Endpoint() | ||
|
||
// Create db container. | ||
dbImg = docker.NewTestDBDocker(t, cfg.DBConfig.DriverName) | ||
cfg.DBConfig.DSN = dbImg.Endpoint() | ||
|
||
// Create l2geth client. | ||
l2Cli, err = ethclient.Dial(cfg.L2Config.Endpoint) | ||
assert.NoError(t, err) | ||
|
||
return err | ||
} | ||
|
||
func free(t *testing.T) { | ||
if dbImg != nil { | ||
assert.NoError(t, dbImg.Stop()) | ||
} | ||
if l1gethImg != nil { | ||
assert.NoError(t, l1gethImg.Stop()) | ||
} | ||
if l2gethImg != nil { | ||
assert.NoError(t, l2gethImg.Stop()) | ||
} | ||
} | ||
|
||
func TestFunction(t *testing.T) { | ||
if err := setupEnv(t); err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
// Run l2 watcher test cases. | ||
t.Run("TestCreateNewWatcherAndStop", testCreateNewWatcherAndStop) | ||
t.Run("TestMonitorBridgeContract", testMonitorBridgeContract) | ||
t.Run("TestFetchMultipleSentMessageInOneBlock", testFetchMultipleSentMessageInOneBlock) | ||
t.Run("TestTraceHasUnsupportedOpcodes", testTraceHasUnsupportedOpcodes) | ||
|
||
// Run l2 relayer test cases. | ||
t.Run("TestCreateNewRelayer", testCreateNewRelayer) | ||
t.Run("TestL2RelayerProcessSaveEvents", testL2RelayerProcessSaveEvents) | ||
t.Run("TestL2RelayerProcessPendingBlocks", testL2RelayerProcessPendingBlocks) | ||
t.Run("TestL2RelayerProcessCommittedBlocks", testL2RelayerProcessCommittedBlocks) | ||
|
||
t.Cleanup(func() { | ||
free(t) | ||
}) | ||
} |
Oops, something went wrong.