@@ -621,14 +621,16 @@ func TestBareEvents(t *testing.T) {
621
621
// TestUnpackEvent is based on this contract:
622
622
// contract T {
623
623
// event received(address sender, uint amount, bytes memo);
624
+ // event receivedAddr(address sender);
624
625
// function receive(bytes memo) external payable {
625
626
// received(msg.sender, msg.value, memo);
627
+ // receivedAddr(msg.sender);
626
628
// }
627
629
// }
628
630
// When receive("X") is called with sender 0x00... and value 1, it produces this tx receipt:
629
631
// receipt{status=1 cgas=23949 bloom=00000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000040200000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 logs=[log: b6818c8064f645cd82d99b59a1a267d6d61117ef [75fd880d39c1daf53b6547ab6cb59451fc6452d27caa90e5b6649dd8293b9eed] 000000000000000000000000376c47978271565f56deb45495afa69e59c16ab200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000158 9ae378b6d4409eada347a5dc0c180f186cb62dc68fcc0f043425eb917335aa28 0 95d429d309bb9d753954195fe2d69bd140b4ae731b9b5b605c34323de162cf00 0]}
630
632
func TestUnpackEvent (t * testing.T ) {
631
- const abiJSON = `[{"constant":false,"inputs":[{"name":"memo","type":"bytes"}],"name":"receive","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"sender","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"memo","type":"bytes"}],"name":"received","type":"event"}]`
633
+ const abiJSON = `[{"constant":false,"inputs":[{"name":"memo","type":"bytes"}],"name":"receive","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"sender","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"memo","type":"bytes"}],"name":"received","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"sender","type":"address"}],"name":"receivedAddr","type":"event"} ]`
632
634
abi , err := JSON (strings .NewReader (abiJSON ))
633
635
if err != nil {
634
636
t .Fatal (err )
@@ -656,6 +658,17 @@ func TestUnpackEvent(t *testing.T) {
656
658
} else {
657
659
t .Logf ("len(data): %d; received event: %+v" , len (data ), ev )
658
660
}
661
+
662
+ type ReceivedAddrEvent struct {
663
+ Address common.Address
664
+ }
665
+ var receivedAddrEv ReceivedAddrEvent
666
+ err = abi .Unpack (& receivedAddrEv , "receivedAddr" , data )
667
+ if err != nil {
668
+ t .Error (err )
669
+ } else {
670
+ t .Logf ("len(data): %d; received event: %+v" , len (data ), receivedAddrEv )
671
+ }
659
672
}
660
673
661
674
func TestABI_MethodById (t * testing.T ) {
0 commit comments