-
Notifications
You must be signed in to change notification settings - Fork 0
/
simulatedClient_test.go
43 lines (35 loc) · 1.19 KB
/
simulatedClient_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 main
import (
"SimulatedEthBackend/ethutils"
ipfs "SimulatedEthBackend/ipfsutils"
"fmt"
"math/big"
"testing"
"time"
"github.com/ethereum/go-ethereum/common"
)
var testPrivatekey = "f11b79dcb87e3811bad41cc68b86d07194c1a2fc70e5b9895b29049cc4357c68"
var testAccountAddress = "0x894432959D4A3e11B3355c4ed1cd79C6795308b2"
var testIpfsManager, _ = ipfs.NewManager("localhost:5001", time.Second)
var done = make(chan bool)
var hashes = make([]common.Hash, 0)
var testReciepts chan string
func TestPrintReciept(t *testing.T) {
testReciepts = PrintReciept(done)
}
func TestCheckForReciepts(t *testing.T) {
testSimulatingClient := ethutils.SimlatingClient(testPrivatekey)
instance, _, tx := ethutils.Deploy(testPrivatekey, testSimulatingClient)
hashes = append(hashes, tx.Hash())
uintb, _ := instance.GetB()
tx1, _ := instance.SetB(big.NewInt(1))
testSimulatingClient.Commit()
hashes = append(hashes, tx1.Hash())
addressa, _ := instance.GetA()
tx2, _ := instance.SetA()
testSimulatingClient.Commit()
hashes = append(hashes, tx2.Hash())
fmt.Println("uint b", uintb)
fmt.Println("address a", addressa.Hex())
CheckForReciepts(hashes, testReciepts, testSimulatingClient, testIpfsManager)
}