Skip to content

Commit

Permalink
PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
skosito committed Apr 9, 2024
1 parent 717fc3f commit 04916f6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* [1936](https://github.com/zeta-chain/node/pull/1936) - refactor common package into subpackages and rename to pkg
* [1966](https://github.com/zeta-chain/node/pull/1966) - move TSS vote message from crosschain to observer
* [1853](https://github.com/zeta-chain/node/pull/1853) - refactor vote inbound tx and vote outbound tx
* [2001](https://github.com/zeta-chain/node/pull/2001) - replace broadcast mode block with sync

### Features

Expand Down Expand Up @@ -59,7 +60,6 @@
* [1941](https://github.com/zeta-chain/node/pull/1941) - add unit tests for zetabridge package
* [1985](https://github.com/zeta-chain/node/pull/1985) - improve fungible module coverage
* [1992](https://github.com/zeta-chain/node/pull/1992) - remove setupKeeper from crosschain module
* [2001](https://github.com/zeta-chain/node/pull/2001) - replace broadcast mode block with sync

### Fixes

Expand Down
33 changes: 19 additions & 14 deletions e2e/txserver/zeta_tx_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ const EmissionsPoolAddress = "zeta1w43fn2ze2wyhu5hfmegr6vp52c3dgn0srdgymy"

// ZetaTxServer is a ZetaChain tx server for E2E test
type ZetaTxServer struct {
clientCtx client.Context
txFactory tx.Factory
name []string
mnemonic []string
address []string
clientCtx client.Context
txFactory tx.Factory
name []string
mnemonic []string
address []string
blockTimeout time.Duration
}

// NewZetaTxServer returns a new TxServer with provided account
Expand Down Expand Up @@ -105,11 +106,12 @@ func NewZetaTxServer(rpcAddr string, names []string, mnemonics []string, chainID
txf := newFactory(clientCtx)

return ZetaTxServer{
clientCtx: clientCtx,
txFactory: txf,
name: names,
mnemonic: mnemonics,
address: addresses,
clientCtx: clientCtx,
txFactory: txf,
name: names,
mnemonic: mnemonics,
address: addresses,
blockTimeout: 1 * time.Minute,
}, nil
}

Expand Down Expand Up @@ -160,6 +162,7 @@ func (zts ZetaTxServer) GetAccountMnemonic(index int) string {
}

// BroadcastTx broadcasts a tx to ZetaChain with the provided msg from the account
// and waiting for blockTime for tx to be included in the block
func (zts ZetaTxServer) BroadcastTx(account string, msg sdktypes.Msg) (*sdktypes.TxResponse, error) {
// Find number and sequence and set it
acc, err := zts.clientCtx.Keyring.Key(account)
Expand Down Expand Up @@ -191,7 +194,10 @@ func (zts ZetaTxServer) BroadcastTx(account string, msg sdktypes.Msg) (*sdktypes
return nil, err
}

// Broadcast tx and wait 10 mins to be included in block
return broadcastWithBlockTimeout(zts, txBytes)
}

func broadcastWithBlockTimeout(zts ZetaTxServer, txBytes []byte) (*sdktypes.TxResponse, error) {
res, err := zts.clientCtx.BroadcastTx(txBytes)
if err != nil {
if res == nil {
Expand All @@ -204,16 +210,15 @@ func (zts ZetaTxServer) BroadcastTx(account string, msg sdktypes.Msg) (*sdktypes
}, err
}

var blockTimeout time.Duration = 10 * time.Minute
exitAfter := time.After(blockTimeout)
exitAfter := time.After(zts.blockTimeout)
hash, err := hex.DecodeString(res.TxHash)
if err != nil {
return nil, err
}
for {
select {
case <-exitAfter:
return nil, fmt.Errorf("timed out after waiting for tx to get included in the block: %d", blockTimeout)
return nil, fmt.Errorf("timed out after waiting for tx to get included in the block: %d", zts.blockTimeout)
case <-time.After(time.Millisecond * 100):
resTx, err := zts.clientCtx.Client.Tx(context.TODO(), hash, false)
if err == nil {
Expand Down

0 comments on commit 04916f6

Please sign in to comment.