Skip to content

Commit

Permalink
fix: resolve errors in vm and wallet tests
Browse files Browse the repository at this point in the history
  • Loading branch information
niklr committed May 24, 2022
1 parent c061578 commit e56c40c
Show file tree
Hide file tree
Showing 11 changed files with 204 additions and 454 deletions.
12 changes: 5 additions & 7 deletions client/abi_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ import (
)

func TestAbiCli_CallOffChain(t *testing.T) {
rpc, err := NewRpcClient(RawUrl)
if err != nil {
t.Error(err)
return
}
t.Skip("Skipped by default. This test can be used to call off-chain contract methods.")

rpc := PreTestRpc(t, RawUrl)

abi := ``
offchainCode := ``
Expand All @@ -34,10 +32,11 @@ func TestAbiCli_CallOffChain(t *testing.T) {
for k, v := range result {
t.Log(k, v)
}

}

func TestUnpack(t *testing.T) {
t.Skip("Skipped by default. This test can be used to unpack contract methods.")

abiCode := ``
contract, err := abi.JSONToABIContract(strings.NewReader(abiCode))
assert.NoError(t, err)
Expand All @@ -54,5 +53,4 @@ func TestUnpack(t *testing.T) {
assert.NoError(t, err)

t.Log(inputs)

}
70 changes: 33 additions & 37 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ func init() {

var Wallet2 *entropystore.Manager

func PreTestRpc(t *testing.T, rawurl string) (RpcClient) {
rpc, err := NewRpcClient(rawurl)
if err != nil {
t.Skipf("Skipping RPC test: %+v", err)
}
height := rpc.GetSnapshotChainHeight()
if height == "" {
t.Skip("Skipping RPC test due to empty SnapshotChainHeight")
}
fmt.Printf("Height: %s\n", height)
return rpc
}

func PreTest() error {
w := wallet.New(&config.Wallet{
DataDir: WalletDir,
Expand All @@ -34,23 +47,20 @@ func PreTest() error {

w2, err := w.RecoverEntropyStoreFromMnemonic("extend excess vibrant crop split vehicle order veteran then fog panel appear frozen deer logic path yard tenant bag nuclear witness annual silent fold", "123456")
if err != nil {
fmt.Errorf("wallet error, %+v", err)
return err
return fmt.Errorf("wallet error, %+v", err)
}
err = w2.Unlock("123456")
if err != nil {

fmt.Errorf("wallet error, %+v", err)
return err
return fmt.Errorf("wallet error, %+v", err)
}

Wallet2 = w2

return nil
}

func TestWallet(t *testing.T) {
err := PreTest()
if err != nil {
if err := PreTest(); err != nil {
t.Error(err)
t.FailNow()
}
Expand Down Expand Up @@ -81,15 +91,13 @@ func TestWallet(t *testing.T) {
}

func TestClient_SubmitRequestTx(t *testing.T) {
t.Skip("Skipped by default. This test can be used to submit a request transaction.")

if err := PreTest(); err != nil {
t.Error(err)
t.FailNow()
}
rpc, err := NewRpcClient(RawUrl)
if err != nil {
t.Error(err)
return
}
rpc := PreTestRpc(t, RawUrl)

client, e := NewClient(rpc)
if e != nil {
Expand Down Expand Up @@ -132,15 +140,13 @@ func TestClient_SubmitRequestTx(t *testing.T) {
}

func TestClient_CreateContract(t *testing.T) {
t.Skip("Skipped by default. This test can be used to create a contract.")

if err := PreTest(); err != nil {
t.Error(err)
t.FailNow()
}
rpc, err := NewRpcClient(RawUrl)
if err != nil {
t.Error(err)
return
}
rpc := PreTestRpc(t, RawUrl)

client, e := NewClient(rpc)
if e != nil {
Expand Down Expand Up @@ -183,19 +189,20 @@ func TestClient_CreateContract(t *testing.T) {
}

func TestClient_SubmitResponseTx(t *testing.T) {
PreTest()
to, err := types.HexToAddress("vite_2ca3c5f1f18b38f865eb47196027ae0c50d0c21e67774abdda")
if err != nil {
t.Skip("Skipped by default. This test can be used to submit a response transaction.")

if err := PreTest(); err != nil {
t.Error(err)
return
t.FailNow()
}
rpc := PreTestRpc(t, RawUrl)

t.Log(to)
rpc, err := NewRpcClient(RawUrl)
to, err := types.HexToAddress("vite_2ca3c5f1f18b38f865eb47196027ae0c50d0c21e67774abdda")
if err != nil {
t.Error(err)
return
}
t.Log(to)

client, e := NewClient(rpc)
if e != nil {
Expand Down Expand Up @@ -228,10 +235,7 @@ func TestClient_SubmitResponseTx(t *testing.T) {
}

func TestClient_QueryOnroad(t *testing.T) {
rpc, err := NewRpcClient(RawUrl)
if err != nil {
t.Fatal(err)
}
rpc := PreTestRpc(t, RawUrl)

addr, err := types.HexToAddress("vite_2ca3c5f1f18b38f865eb47196027ae0c50d0c21e67774abdda")
if err != nil {
Expand All @@ -251,11 +255,7 @@ func TestClient_QueryOnroad(t *testing.T) {
}

func TestClient_GetBalanceAll(t *testing.T) {
rpc, err := NewRpcClient(RawUrl)
if err != nil {
t.Error(err)
return
}
rpc := PreTestRpc(t, RawUrl)

client, e := NewClient(rpc)
if e != nil {
Expand All @@ -282,11 +282,7 @@ func TestClient_GetBalanceAll(t *testing.T) {
}

func TestClient_GetBalance(t *testing.T) {
rpc, err := NewRpcClient(RawUrl)
if err != nil {
t.Error(err)
return
}
rpc := PreTestRpc(t, RawUrl)

client, e := NewClient(rpc)
if e != nil {
Expand Down
Loading

0 comments on commit e56c40c

Please sign in to comment.