forked from livepeer/go-livepeer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackend_test.go
47 lines (39 loc) · 2.97 KB
/
backend_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
44
45
46
47
package eth
import (
"math/big"
"testing"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestNewTxLog(t *testing.T) {
require := require.New(t)
assert := assert.New(t)
// https://etherscan.io/tx/0x6afffe4d95789e7a27bf0ec8adb8324b2e481a5a6df468366e6efffad15746a6
inputs := "_ticket: { Recipient: 0x9C10672CEE058Fd658103d90872fE431bb6C0AFa Sender: 0x3eE860A4abA830AF84EbBCE2b381fc11DB8493e2 FaceValue: 24703611594215916 WinProb: 4687253472865791949219216447262131914283161967982656133076290000000000000000 SenderNonce: 1 RecipientRandHash: 0xd00ef48a6825d9ae93097ad55bc76057fb50afc203aa98fd4e01aa6576d71298 AuxData: 0x0000000000000000000000000000000000000000000000000000000000000689a9f81d59be53a90a12cb12f627aa9e87c505320bad20a98fd98d5ed23bfe9a54 } _sig: 0x5ff5265992f1a6563851d085f363b16ad65416baaee090ee368b59082437df7a0237214659511fc188d6a4ef57c988bb18faa3e99826c78e9e75eb29366745891b _recipientRand: 21160157592767011607011497540409649304524524744605816319294275445072062630355"
tx := types.NewTransaction(
1,
common.HexToAddress("0x5b1ce829384eebfa30286f12d1e7a695ca45f5d2"),
big.NewInt(0),
167221,
big.NewInt(5000000000),
common.Hex2Bytes("ec8b3cb6000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001a02ec8398aed129f376c296c8b999d2f9ee61494110f9a752494d2ef1b89a4c9d30000000000000000000000009c10672cee058fd658103d90872fe431bb6c0afa0000000000000000000000003ee860a4aba830af84ebbce2b381fc11db8493e20000000000000000000000000000000000000000000000000057c3cdc9be11ec0a5ce4361d251fc5d71ba8fa55eef46b5a59a967145c79aa4cdbe1f943ad00000000000000000000000000000000000000000000000000000000000000000001d00ef48a6825d9ae93097ad55bc76057fb50afc203aa98fd4e01aa6576d7129800000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000689a9f81d59be53a90a12cb12f627aa9e87c505320bad20a98fd98d5ed23bfe9a5400000000000000000000000000000000000000000000000000000000000000415ff5265992f1a6563851d085f363b16ad65416baaee090ee368b59082437df7a0237214659511fc188d6a4ef57c988bb18faa3e99826c78e9e75eb29366745891b00000000000000000000000000000000000000000000000000000000000000"),
)
abis, err := makeABIMap()
require.Nil(err)
b := &backend{
abiMap: abis,
}
txLog, err := b.newTxLog(tx)
assert.Equal("redeemWinningTicket", txLog.method)
assert.Equal(inputs, txLog.inputs)
// test unknown ABI
tx = types.NewTransaction(2, common.HexToAddress("foo"), big.NewInt(0), 200000, big.NewInt(1000000), common.Hex2Bytes("aaaabbbb"))
txLog, err = b.newTxLog(tx)
assert.EqualError(err, "unknown ABI")
// test no method signature
tx = types.NewTransaction(2, common.HexToAddress("foo"), big.NewInt(0), 200000, big.NewInt(1000000), nil)
txLog, err = b.newTxLog(tx)
assert.EqualError(err, "no method signature")
}