-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathethutils_test.go
More file actions
29 lines (24 loc) · 1005 Bytes
/
ethutils_test.go
File metadata and controls
29 lines (24 loc) · 1005 Bytes
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
package ethcontract
import (
"fmt"
"math/big"
"testing"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/crypto"
)
var testKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
func TestParseTruffleContract(t *testing.T) {
backend := backends.NewSimulatedBackend(core.GenesisAlloc{
crypto.PubkeyToAddress(testKey.PublicKey): {Balance: big.NewInt(10000000000)},
})
// eclient, err := NewEthUtil("http://localhost:8545")
eclient := &EClient{conn: backend, LastTranasction: &ETransact{}, auth: bind.NewKeyedTransactor(testKey)}
truffleFile := "examples/truffle_contract/blockssh.json"
address, err := eclient.DeployContractTruffleFromFile(truffleFile)
if err != nil {
t.Fatalf("Failed to deploy contract: %v", err)
}
fmt.Printf("Deployed truffle contract -%s to address 0x%x \n\n", truffleFile, address)
}