Skip to content

Commit b750c56

Browse files
sh-chabeer-1coderabbitai[bot]
authored
Feat/e2e test (#60)
* refactor node process * refactor node, broadcaster * refactor provider * refactor merkle, types * refactor db * refactor executor * add migration function * change iterate name & append splitter to key when iterating * add LastProcessedBlockHeightKey migration * only change key if it exists * wrap errors to clarify them * wrap errors on key, provider * wrap errors & merge main * makes log as production & add log-format flag * fix reverse iterate finding prev inclusive start key * db test * db stage test * save finalized tree when it exists * merge cmd * merkle test * merkle types test * host deposit & txhandler test * host handler test * keys test * txutil test * child deposit oracle test * refactor child db and add l2 sequence checker into handleInitiateWithdrawal and test * prepare tree, output test * add version to working tree info & child withdrawal test * child handle output test * child db handler query test * executor types test * format * delete oracle msg data from authz msg & oracle test * update batch info test * batch test * add timestamp & tx hash to withdrawals (#54) * add timestamp & tx hash to withdrawals * fix test and lint * delete last block height --------- Co-authored-by: beer-1 <[email protected]> * format * add batch handler test & fix checkbatch test * add some comments * e2e interchaintest setup * add test-e2e to makefile * add syncing query * simple deposit e2e test * syncing query * create connect sidecar container & connect it to l1 * multiple txs e2e test * reconnect node test * batch reconstruction test * tx check err fix * format * bug fix: set bech32 prefix to sdk config before building tx * use celestia custom tx building function * celestia batch reconstruction test * add celestia version to readme * increment page * Update executor/querier.go Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * sync nil check * check msg type url in msgexec * authz msg length check * authz msg length check * increase timeout of e2e test & add minor comments & add e2e to codecov ignore * address function return decoded address --------- Co-authored-by: beer-1 <[email protected]> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent ece493c commit b750c56

26 files changed

+4804
-17
lines changed

.codecov.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ ignore:
3636
- "**/module.go"
3737
- "x/ibc/testing"
3838
- "testing/"
39+
- "e2e/"

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ format:
8989
### Tests
9090
###############################################################################
9191

92-
test: test-unit
92+
test: test-unit test-e2e
9393

9494
test-all: test-unit test-race test-cover
9595

@@ -102,10 +102,13 @@ test-race:
102102
test-cover:
103103
@go test -mod=readonly -timeout 30m -race -coverprofile=coverage.txt -covermode=atomic -tags='ledger test_ledger_mock' ./...
104104

105+
test-e2e:
106+
cd e2e && go test -v . -timeout 30m
107+
105108
benchmark:
106109
@go test -timeout 20m -mod=readonly -bench=. ./...
107110

108-
.PHONY: test test-all test-cover test-unit test-race benchmark
111+
.PHONY: test test-all test-cover test-unit test-race test-e2e benchmark
109112

110113
###############################################################################
111114
### Protobuf ###

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ Before running OPinit bots, make sure you have the following prerequisites insta
1717

1818
To ensure compatibility with the node version, check the following versions:
1919

20-
| L1 Node | MiniMove | MiniWasm | MiniEVM |
21-
| ------- | -------- | -------- | ------- |
22-
| v0.6.4+ | v0.6.5+ | v0.6.5+ | v0.6.7+ |
20+
| L1 Node | MiniMove | MiniWasm | MiniEVM | Celestia-appd |
21+
| ------- | -------- | -------- | ------- | ------------- |
22+
| v0.6.4+ | v0.6.5+ | v0.6.5+ | v0.6.7+ | v3.2.0+ |
2323

2424
### Build and Configure
2525

challenger/challenger.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,14 @@ func (c *Challenger) RegisterQuerier() {
225225
}
226226
return ctx.JSON(pendingEvents)
227227
})
228+
229+
c.server.RegisterQuerier("/syncing", func(ctx *fiber.Ctx) error {
230+
status, err := c.GetStatus()
231+
if err != nil {
232+
return err
233+
}
234+
return ctx.JSON(*status.Host.Node.Syncing && *status.Child.Node.Syncing)
235+
})
228236
}
229237

230238
func (c *Challenger) getNodeStartHeights(ctx types.Context, bridgeId uint64) (l1StartHeight int64, l2StartHeight int64, startOutputIndex uint64, err error) {
@@ -283,7 +291,6 @@ func (c *Challenger) getNodeStartHeights(ctx types.Context, bridgeId uint64) (l1
283291
}
284292
}
285293
}
286-
287294
return
288295
}
289296

challenger/db/db.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,15 @@ func LoadChallenges(db types.DB) (challenges []challengertypes.Challenge, err er
8989

9090
func DeleteFutureChallenges(db types.DB, initialBlockTime time.Time) error {
9191
deletingKeys := make([][]byte, 0)
92-
iterErr := db.Iterate(challengertypes.ChallengeKey, challengertypes.PrefixedChallengeEventTime(initialBlockTime), func(key []byte, _ []byte) (stop bool, err error) {
92+
iterErr := db.ReverseIterate(challengertypes.ChallengeKey, nil, func(key []byte, _ []byte) (stop bool, err error) {
93+
ts, _, err := challengertypes.ParseChallenge(key)
94+
if err != nil {
95+
return true, err
96+
}
97+
if !ts.After(initialBlockTime) {
98+
return true, nil
99+
}
100+
93101
deletingKeys = append(deletingKeys, key)
94102
return false, nil
95103
})

cmd/opinitd/key.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@ import (
3535
)
3636

3737
const (
38-
flagRecover = "recover"
39-
flagMnemonicSrc = "source"
40-
flagBech32Prefix = "bech32"
41-
flagOutput = "output"
38+
flagRecover = "recover"
39+
flagMnemonicSrc = "source"
40+
flagMnemonicString = "mnemonic"
41+
flagBech32Prefix = "bech32"
42+
flagOutput = "output"
4243
)
4344

4445
type keyJsonOutput map[string]keyJsonOutputElem
@@ -79,6 +80,7 @@ $ keys add localnet key1
7980
$ keys add l2 key2 --bech32 celestia
8081
$ keys add l2 key2 --recover
8182
$ keys add l2 key2 --recover --source mnemonic.txt
83+
$ keys add l2 key2 --recover --mnemonic "[mnemonic...]"
8284
$ keys add l2 key2 --output json`),
8385
RunE: func(cmd *cobra.Command, args []string) error {
8486
chainId := args[0]
@@ -106,9 +108,12 @@ $ keys add l2 key2 --output json`),
106108
mnemonic := ""
107109
recoverFlag, _ := cmd.Flags().GetBool(flagRecover)
108110
mnemonicSrc, _ := cmd.Flags().GetString(flagMnemonicSrc)
111+
mnemonicString, _ := cmd.Flags().GetString(flagMnemonicString)
109112

110113
if recoverFlag {
111-
if mnemonicSrc != "" {
114+
if mnemonicString != "" {
115+
mnemonic = mnemonicString
116+
} else if mnemonicSrc != "" {
112117
file, err := os.Open(mnemonicSrc)
113118
if err != nil {
114119
return err
@@ -172,6 +177,7 @@ $ keys add l2 key2 --output json`),
172177
}
173178
cmd.Flags().Bool(flagRecover, false, "Provide seed phrase to recover existing key instead of creating")
174179
cmd.Flags().String(flagMnemonicSrc, "", "Import mnemonic from a file")
180+
cmd.Flags().String(flagMnemonicString, "", "Import mnemonic from string")
175181
cmd.Flags().String(flagBech32Prefix, "init", "Bech32 prefix")
176182
cmd.Flags().String(flagOutput, "plain", "Output format (plain|json)")
177183
return cmd

0 commit comments

Comments
 (0)