11package evm
22
33import (
4+ "bytes"
5+ "math/big"
6+
47 _ "github.com/xuperchain/xupercore/bcs/contract/evm"
58 _ "github.com/xuperchain/xupercore/bcs/contract/native"
69 _ "github.com/xuperchain/xupercore/bcs/contract/xvm"
710 "github.com/xuperchain/xupercore/kernel/contract/sandbox"
811 "github.com/xuperchain/xupercore/protos"
9- "math/big"
1012
1113 "encoding/hex"
14+ "io/ioutil"
15+ "testing"
16+
1217 "github.com/xuperchain/xupercore/kernel/contract"
1318 _ "github.com/xuperchain/xupercore/kernel/contract"
1419 _ "github.com/xuperchain/xupercore/kernel/contract/kernel"
1520 _ "github.com/xuperchain/xupercore/kernel/contract/manager"
1621 "github.com/xuperchain/xupercore/kernel/contract/mock"
17- "io/ioutil"
18- "testing"
1922)
2023
2124func TestEVMProxy (t * testing.T ) {
@@ -66,6 +69,7 @@ func TestEVMProxy(t *testing.T) {
6669 if err != nil {
6770 t .Fatal (err )
6871 }
72+ signedTx := []byte ("0xf867808082520894f97798df751deb4b6e39d4cf998ee7cd4dcb9acc880de0b6b3a76400008025a0f0d2396973296cd6a71141c974d4a851f5eae8f08a8fba2dc36a0fef9bd6440ca0171995aa750d3f9f8e4d0eac93ff67634274f3c5acf422723f49ff09a6885422" )
6973 t .Run ("SendRawTransaction" , func (t * testing.T ) {
7074 th .SetUtxoReader (sandbox .NewUTXOReaderFromInput ([]* protos.TxInput {
7175 {
@@ -75,39 +79,52 @@ func TestEVMProxy(t *testing.T) {
7579 }))
7680
7781 resp , err = th .Invoke ("xkernel" , "$evm" , "SendRawTransaction" , map [string ][]byte {
78- "signed_tx" : [] byte ( "0xf867808082520894f97798df751deb4b6e39d4cf998ee7cd4dcb9acc880de0b6b3a76400008025a0f0d2396973296cd6a71141c974d4a851f5eae8f08a8fba2dc36a0fef9bd6440ca0171995aa750d3f9f8e4d0eac93ff67634274f3c5acf422723f49ff09a6885422" ) ,
82+ "signed_tx" : signedTx ,
7983 "tx_hash" : []byte ("tx_hash" ),
8084 })
8185 if err != nil {
8286 t .Error (err )
8387 return
8488 }
8589 })
86-
87- t .Run ("ContractCall" , func (t * testing.T ) {
88- resp , err = th .Invoke ("xkernel" , "$evm" , "ContractCall" , map [string ][]byte {
89- "to" : []byte ("313131312D2D2D2D2D2D2D2D2D636F756E746572" ),
90- "from" : []byte ("b60e8dd61c5d32be8058bb8eb970870f07233155" ),
91- "input" : []byte ("ae896c870000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000678636861696e0000000000000000000000000000000000000000000000000000" ),
90+ t .Run ("GetTransactionReceipt" , func (t * testing.T ) {
91+ resp , err := th .Invoke ("xkernel" , "$evm" , "GetTransactionReceipt" , map [string ][]byte {
92+ "tx_hash" : []byte ("tx_hash" ),
9293 })
9394 if err != nil {
9495 t .Error (err )
9596 return
9697 }
97- resp , err = th .Invoke ("evm" , "counter" , "get" , map [string ][]byte {
98- "input" : []byte (`{"key":"xchain"}` ),
99- "jsonEncoded" : []byte ("true" ),
100- })
101- if err != nil {
98+ if ! bytes .Equal (resp .Body , signedTx ) {
10299 t .Error (err )
103100 return
104101 }
105- if string (resp .Body ) != `[{"0":"1"}]` {
106- t .Errorf ("expect %s,get:%s" , `[{"0":"1"}]` , string (resp .Body ))
107- return
108- }
109-
110102 })
103+
104+ // t.Run("ContractCall", func(t *testing.T) {
105+ // resp, err = th.Invoke("xkernel", "$evm", "ContractCall", map[string][]byte{
106+ // "to": []byte("313131312D2D2D2D2D2D2D2D2D636F756E746572"),
107+ // "from": []byte("b60e8dd61c5d32be8058bb8eb970870f07233155"),
108+ // "input": []byte("ae896c870000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000678636861696e0000000000000000000000000000000000000000000000000000"),
109+ // })
110+ // if err != nil {
111+ // t.Error(err)
112+ // return
113+ // }
114+ // resp, err = th.Invoke("evm", "counter", "get", map[string][]byte{
115+ // "input": []byte(`{"key":"xchain"}`),
116+ // "jsonEncoded": []byte("true"),
117+ // })
118+ // if err != nil {
119+ // t.Error(err)
120+ // return
121+ // }
122+ // if string(resp.Body) != `[{"0":"1"}]` {
123+ // t.Errorf("expect %s,get:%s", `[{"0":"1"}]`, string(resp.Body))
124+ // return
125+ // }
126+ //
127+ // })
111128 _ = resp
112129}
113130
0 commit comments