Skip to content

Commit

Permalink
wip: watchdog tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberhorsey committed Feb 7, 2024
1 parent 642c616 commit 1f65a60
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions packages/relayer/watchdog/watchdog_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package watchdog

import (
"context"
"math/big"
"testing"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/stretchr/testify/assert"
"github.com/taikoxyz/taiko-mono/packages/relayer/pkg/mock"
)

func Test_Name(t *testing.T) {
w := Watchdog{}

assert.Equal(t, "watchdog", w.Name())
}

func Test_queueName(t *testing.T) {
w := Watchdog{
srcChainId: big.NewInt(1),
destChainId: big.NewInt(2),
}

assert.Equal(t, "1-2-MessageReceived-queue", w.queueName())
}

func Test_setLatestNonce(t *testing.T) {
w := Watchdog{
destNonce: 0,
}

w.setLatestNonce(100)

assert.Equal(t, w.destNonce, uint64(100))
}

func Test_getLatestNonce(t *testing.T) {
w := Watchdog{
destEthClient: &mock.EthClient{},
}

auth := &bind.TransactOpts{}

err := w.getLatestNonce(context.Background(), auth)

assert.Nil(t, err)

assert.Equal(t, auth.Nonce, new(big.Int).SetUint64(mock.PendingNonce))

assert.Equal(t, w.destNonce, mock.PendingNonce)
}

0 comments on commit 1f65a60

Please sign in to comment.