Skip to content

Commit

Permalink
Update basic_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
learnforpractice committed Jul 19, 2022
1 parent c41e492 commit abdaa91
Showing 1 changed file with 6 additions and 40 deletions.
46 changes: 6 additions & 40 deletions tests/testdebugging/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ package main

import (
"context"
"encoding/hex"
"fmt"
"os"
"testing"

"github.com/learnforpractice/chaintester"
Expand Down Expand Up @@ -51,61 +48,30 @@ func TestHello(t *testing.T) {
}`
tester.PushAction("eosio", "updateauth", updateAuthArgs, permissions)

wasm, _ := os.ReadFile("test.wasm")
abi, _ := os.ReadFile("test.abi")

hexWasm := make([]byte, len(wasm)*2)
hex.Encode(hexWasm, wasm)
setCodeArgs := fmt.Sprintf(
`
{
"account": "%s",
"vmtype": 0,
"vmversion": 0,
"code": "%s"
}
`,
"hello",
string(hexWasm),
)

ret, err := tester.PushAction("eosio", "setcode", setCodeArgs, permissions)
err := tester.DeployContract("hello", "test.wasm", "test.abi")
if err != nil {
panic(err)
}
tester.ProduceBlock()

rawAbi, _ := tester.PackAbi(string(abi))
hexRawAbi := make([]byte, len(rawAbi)*2)
hex.Encode(hexRawAbi, rawAbi)
setAbiArgs := fmt.Sprintf(
`
{
"account": "%s",
"abi": "%s"
}
`,
"hello",
string(hexRawAbi),
)
ret, err = tester.PushAction("eosio", "setabi", setAbiArgs, permissions)

args := `
{
"name": "Go"
}
`
permissions2 := string(permissions)
for i := 0; i < 1; i++ {
ret, err = tester.PushAction("hello", "sayhello", args, permissions)
tester.PackAbi(string(abi))
_, err = tester.PushAction("hello", "sayhello", args, permissions)
if err != nil {
panic(err)
}
tester.ProduceBlock()
}

// defer chaintester.GetApplyRequestServer().Stop()
// defer chaintester.CloseVMAPI()

ret, err = tester.PushAction("hello", "sayhello", args, permissions2)
ret, err := tester.PushAction("hello", "sayhello", args, permissions2)
tester.ProduceBlock()

ret, err = tester.PushAction("hello", "inc", "", permissions2)
Expand Down

0 comments on commit abdaa91

Please sign in to comment.