forked from smartcontractkit/chainlink
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblocks_commands_test.go
43 lines (33 loc) · 1.18 KB
/
blocks_commands_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package cmd_test
import (
"flag"
"math/big"
"testing"
"github.com/stretchr/testify/require"
"github.com/urfave/cli"
"github.com/smartcontractkit/chainlink/v2/core/services/chainlink"
"github.com/smartcontractkit/chainlink/v2/core/utils"
)
func Test_ReplayFromBlock(t *testing.T) {
t.Parallel()
app := startNewApplicationV2(t, func(c *chainlink.Config, s *chainlink.Secrets) {
c.EVM[0].ChainID = (*utils.Big)(big.NewInt(5))
c.EVM[0].Enabled = ptr(true)
})
client, _ := app.NewShellAndRenderer()
set := flag.NewFlagSet("test", 0)
flagSetApplyFromAction(client.ReplayFromBlock, set, "")
//Incorrect block number
require.NoError(t, set.Set("block-number", "0"))
c := cli.NewContext(nil, set, nil)
require.ErrorContains(t, client.ReplayFromBlock(c), "Must pass a positive value in")
//Incorrect chain ID
require.NoError(t, set.Set("block-number", "1"))
require.NoError(t, set.Set("evm-chain-id", "1"))
c = cli.NewContext(nil, set, nil)
require.ErrorContains(t, client.ReplayFromBlock(c), "does not match any local chains")
//Correct chain ID
require.NoError(t, set.Set("evm-chain-id", "5"))
c = cli.NewContext(nil, set, nil)
require.NoError(t, client.ReplayFromBlock(c))
}