forked from gnolang/gno
-
Notifications
You must be signed in to change notification settings - Fork 0
/
genesis_txs_list_test.go
71 lines (56 loc) · 1.38 KB
/
genesis_txs_list_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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package main
import (
"bytes"
"context"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/gnolang/gno/gno.land/pkg/gnoland"
"github.com/gnolang/gno/tm2/pkg/commands"
"github.com/gnolang/gno/tm2/pkg/testutils"
)
func TestGenesis_List_All(t *testing.T) {
t.Parallel()
t.Run("invalid genesis path", func(t *testing.T) {
t.Parallel()
// Create the command
cmd := newRootCmd(commands.NewTestIO())
args := []string{
"genesis",
"txs",
"list",
"--genesis-path",
"",
}
// Run the command
cmdErr := cmd.ParseAndRun(context.Background(), args)
assert.ErrorIs(t, cmdErr, errUnableToLoadGenesis)
})
t.Run("list all txs", func(t *testing.T) {
t.Parallel()
tempGenesis, cleanup := testutils.NewTestFile(t)
t.Cleanup(cleanup)
// Generate dummy txs
txs := generateDummyTxs(t, 10)
genesis := getDefaultGenesis()
genesis.AppState = gnoland.GnoGenesisState{
Txs: txs,
}
require.NoError(t, genesis.SaveAs(tempGenesis.Name()))
cio := commands.NewTestIO()
buf := bytes.NewBuffer(nil)
cio.SetOut(commands.WriteNopCloser(buf))
cmd := newRootCmd(cio)
args := []string{
"genesis",
"txs",
"list",
"--genesis-path",
tempGenesis.Name(),
}
// Run the command
cmdErr := cmd.ParseAndRun(context.Background(), args)
require.NoError(t, cmdErr)
require.Len(t, buf.String(), 4442)
})
}