-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcontract_test.go
More file actions
42 lines (35 loc) · 1.08 KB
/
contract_test.go
File metadata and controls
42 lines (35 loc) · 1.08 KB
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
package listener
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/ethereum/go-ethereum/common"
)
var _ = Describe("Contract tests", func() {
Context("NewContract tests", func() {
It("valid abi file", func() {
const name = "test_contract"
const abi = `
[
{ "type" : "function", "name" : "send", "constant" : false, "inputs" : [ { "name" : "amount", "type" : "uint256" } ] },
{ "type" : "event", "name" : "balance" }
]`
addr := common.StringToAddress("0x1234567890")
c, err := NewContract(name, abi, addr)
Expect(err).Should(BeNil())
Expect(name).Should(Equal(c.Name))
Expect(addr).Should(Equal(c.Address))
Expect(c.ABI).ShouldNot(BeNil())
Expect(len(c.events)).Should(BeNumerically("==", 1))
for _, event := range c.ABI.Events {
Expect(c.events[event.Id()]).ShouldNot(BeNil())
}
})
It("invalid abi file", func() {
const name = "test_contract"
const abi = `wrong abi files`
addr := common.StringToAddress("0x1234567890")
_, err := NewContract(name, abi, addr)
Expect(err).ShouldNot(BeNil())
})
})
})