Skip to content

Commit

Permalink
Feat/e2e test (#60)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
3 people authored Jan 6, 2025
1 parent ece493c commit b750c56
Show file tree
Hide file tree
Showing 26 changed files with 4,804 additions and 17 deletions.
1 change: 1 addition & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ ignore:
- "**/module.go"
- "x/ibc/testing"
- "testing/"
- "e2e/"
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ format:
### Tests
###############################################################################

test: test-unit
test: test-unit test-e2e

test-all: test-unit test-race test-cover

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

test-e2e:
cd e2e && go test -v . -timeout 30m

benchmark:
@go test -timeout 20m -mod=readonly -bench=. ./...

.PHONY: test test-all test-cover test-unit test-race benchmark
.PHONY: test test-all test-cover test-unit test-race test-e2e benchmark

###############################################################################
### Protobuf ###
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ Before running OPinit bots, make sure you have the following prerequisites insta

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

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

### Build and Configure

Expand Down
9 changes: 8 additions & 1 deletion challenger/challenger.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,14 @@ func (c *Challenger) RegisterQuerier() {
}
return ctx.JSON(pendingEvents)
})

c.server.RegisterQuerier("/syncing", func(ctx *fiber.Ctx) error {
status, err := c.GetStatus()
if err != nil {
return err
}
return ctx.JSON(*status.Host.Node.Syncing && *status.Child.Node.Syncing)
})
}

func (c *Challenger) getNodeStartHeights(ctx types.Context, bridgeId uint64) (l1StartHeight int64, l2StartHeight int64, startOutputIndex uint64, err error) {
Expand Down Expand Up @@ -283,7 +291,6 @@ func (c *Challenger) getNodeStartHeights(ctx types.Context, bridgeId uint64) (l1
}
}
}

return
}

Expand Down
10 changes: 9 additions & 1 deletion challenger/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,15 @@ func LoadChallenges(db types.DB) (challenges []challengertypes.Challenge, err er

func DeleteFutureChallenges(db types.DB, initialBlockTime time.Time) error {
deletingKeys := make([][]byte, 0)
iterErr := db.Iterate(challengertypes.ChallengeKey, challengertypes.PrefixedChallengeEventTime(initialBlockTime), func(key []byte, _ []byte) (stop bool, err error) {
iterErr := db.ReverseIterate(challengertypes.ChallengeKey, nil, func(key []byte, _ []byte) (stop bool, err error) {
ts, _, err := challengertypes.ParseChallenge(key)
if err != nil {
return true, err
}
if !ts.After(initialBlockTime) {
return true, nil
}

deletingKeys = append(deletingKeys, key)
return false, nil
})
Expand Down
16 changes: 11 additions & 5 deletions cmd/opinitd/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ import (
)

const (
flagRecover = "recover"
flagMnemonicSrc = "source"
flagBech32Prefix = "bech32"
flagOutput = "output"
flagRecover = "recover"
flagMnemonicSrc = "source"
flagMnemonicString = "mnemonic"
flagBech32Prefix = "bech32"
flagOutput = "output"
)

type keyJsonOutput map[string]keyJsonOutputElem
Expand Down Expand Up @@ -79,6 +80,7 @@ $ keys add localnet key1
$ keys add l2 key2 --bech32 celestia
$ keys add l2 key2 --recover
$ keys add l2 key2 --recover --source mnemonic.txt
$ keys add l2 key2 --recover --mnemonic "[mnemonic...]"
$ keys add l2 key2 --output json`),
RunE: func(cmd *cobra.Command, args []string) error {
chainId := args[0]
Expand Down Expand Up @@ -106,9 +108,12 @@ $ keys add l2 key2 --output json`),
mnemonic := ""
recoverFlag, _ := cmd.Flags().GetBool(flagRecover)
mnemonicSrc, _ := cmd.Flags().GetString(flagMnemonicSrc)
mnemonicString, _ := cmd.Flags().GetString(flagMnemonicString)

if recoverFlag {
if mnemonicSrc != "" {
if mnemonicString != "" {
mnemonic = mnemonicString
} else if mnemonicSrc != "" {
file, err := os.Open(mnemonicSrc)
if err != nil {
return err
Expand Down Expand Up @@ -172,6 +177,7 @@ $ keys add l2 key2 --output json`),
}
cmd.Flags().Bool(flagRecover, false, "Provide seed phrase to recover existing key instead of creating")
cmd.Flags().String(flagMnemonicSrc, "", "Import mnemonic from a file")
cmd.Flags().String(flagMnemonicString, "", "Import mnemonic from string")
cmd.Flags().String(flagBech32Prefix, "init", "Bech32 prefix")
cmd.Flags().String(flagOutput, "plain", "Output format (plain|json)")
return cmd
Expand Down
Loading

0 comments on commit b750c56

Please sign in to comment.