Co-authored-by: Marko <marko@baricevic.me>
This commit is contained in:
parent
826d4d3f28
commit
f25bf6d4f6
@ -3,19 +3,23 @@
|
||||
Test framework for system tests.
|
||||
Starts and interacts with a (multi node) blockchain in Go.
|
||||
Supports
|
||||
|
||||
* CLI
|
||||
* Servers
|
||||
* Events
|
||||
* RPC
|
||||
|
||||
Uses:
|
||||
|
||||
* testify
|
||||
* gjson
|
||||
* sjson
|
||||
Server and client side are executed on the host machine
|
||||
|
||||
## Developer
|
||||
|
||||
### Test strategy
|
||||
|
||||
System tests cover the full stack via cli and a running (multi node) network. They are more expensive (in terms of time/ cpu)
|
||||
to run compared to unit or integration tests.
|
||||
Therefore, we focus on the **critical path** and do not cover every condition.
|
||||
@ -33,7 +37,9 @@ Test cli parameters
|
||||
* `-nodes-count` int - number of nodes in the cluster (default 4)
|
||||
|
||||
# Port ranges
|
||||
|
||||
With *n* nodes:
|
||||
|
||||
* `26657` - `26657+n` - RPC
|
||||
* `1317` - `1317+n` - API
|
||||
* `9090` - `9090+n` - GRPC
|
||||
@ -47,4 +53,4 @@ For example Node *3* listens on `26660` for RPC calls
|
||||
|
||||
## Disclaimer
|
||||
|
||||
This is based on the system test framework in [wasmd](https://github.com/CosmWasm/wasmd) built by Confio.
|
||||
This is based on the system test framework in [wasmd](https://github.com/CosmWasm/wasmd) built by Confio.
|
||||
|
||||
50
tests/systemtests/account_test.go
Normal file
50
tests/systemtests/account_test.go
Normal file
@ -0,0 +1,50 @@
|
||||
package systemtests
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
|
||||
func TestAccountCreation(t *testing.T) {
|
||||
// scenario: test account creation
|
||||
// given a running chain
|
||||
// when accountA is sending funds to accountB,
|
||||
// AccountB should not be created
|
||||
// when accountB is sending funds to accountA,
|
||||
// AccountB should be created
|
||||
|
||||
sut.ResetChain(t)
|
||||
cli := NewCLIWrapper(t, sut, verbose)
|
||||
// add genesis account with some tokens
|
||||
account1Addr := cli.AddKey("account1")
|
||||
account2Addr := cli.AddKey("account2")
|
||||
sut.ModifyGenesisCLI(t,
|
||||
[]string{"genesis", "add-genesis-account", account1Addr, "10000000stake"},
|
||||
)
|
||||
|
||||
sut.StartChain(t)
|
||||
|
||||
// query account1
|
||||
rsp := cli.CustomQuery("q", "auth", "account", account1Addr)
|
||||
assert.Equal(t, account1Addr, gjson.Get(rsp, "account.value.address").String(), rsp)
|
||||
|
||||
rsp1 := cli.Run("tx", "bank", "send", account1Addr, account2Addr, "5000stake", "--from="+account1Addr, "--fees=1stake")
|
||||
RequireTxSuccess(t, rsp1)
|
||||
|
||||
// query account2
|
||||
|
||||
rsp2 := cli.WithRunErrorsIgnored().CustomQuery("q", "auth", "account", account2Addr)
|
||||
assert.True(t, strings.Contains(rsp2, "not found: key not found"))
|
||||
|
||||
rsp3 := cli.Run("tx", "bank", "send", account2Addr, account1Addr, "1000stake", "--from="+account1Addr, "--fees=1stake")
|
||||
RequireTxSuccess(t, rsp3)
|
||||
|
||||
// query account2 to make sure its created
|
||||
rsp4 := cli.CustomQuery("q", "auth", "account", account2Addr)
|
||||
assert.Equal(t, "1", gjson.Get(rsp4, "account.value.sequence").String(), rsp4)
|
||||
rsp5 := cli.CustomQuery("q", "auth", "account", account1Addr)
|
||||
assert.Equal(t, "1", gjson.Get(rsp5, "account.value.sequence").String(), rsp5)
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user