diff options
author | obscuren <geffobscura@gmail.com> | 2015-03-10 08:22:38 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-03-10 08:22:38 +0800 |
commit | 0db4a0e898d09ffa7b6b1289e9a334edc0001cfa (patch) | |
tree | a0b5c8381ab482550ef4800a06d4db086d76a983 /ethutil/natspec/natspec_test.go | |
parent | 94e543bc398efbb5c712b6e4cb48d8a57eb3400d (diff) | |
parent | 0d64163fea3a266ceb71cb4c4ee5682052c9ca6c (diff) | |
download | go-tangerine-0db4a0e898d09ffa7b6b1289e9a334edc0001cfa.tar go-tangerine-0db4a0e898d09ffa7b6b1289e9a334edc0001cfa.tar.gz go-tangerine-0db4a0e898d09ffa7b6b1289e9a334edc0001cfa.tar.bz2 go-tangerine-0db4a0e898d09ffa7b6b1289e9a334edc0001cfa.tar.lz go-tangerine-0db4a0e898d09ffa7b6b1289e9a334edc0001cfa.tar.xz go-tangerine-0db4a0e898d09ffa7b6b1289e9a334edc0001cfa.tar.zst go-tangerine-0db4a0e898d09ffa7b6b1289e9a334edc0001cfa.zip |
Merge branch 'poc-9' into develop
Diffstat (limited to 'ethutil/natspec/natspec_test.go')
-rw-r--r-- | ethutil/natspec/natspec_test.go | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/ethutil/natspec/natspec_test.go b/ethutil/natspec/natspec_test.go new file mode 100644 index 000000000..48a9cb25c --- /dev/null +++ b/ethutil/natspec/natspec_test.go @@ -0,0 +1,51 @@ +package natspec + +import ( + "testing" +) + +func TestNotice(t *testing.T) { + + ns, err := NewNATSpec(` + { + "jsonrpc": "2.0", + "method": "eth_call", + "params": [{ + "to": "0x8521742d3f456bd237e312d6e30724960f72517a", + "data": "0xc6888fa1000000000000000000000000000000000000000000000000000000000000007a" + }], + "id": 6 + } + `) + + if err != nil { + t.Errorf("NewNATSpec error %v", err) + } + + ns.SetABI(` + [{ + "name": "multiply", + "constant": false, + "type": "function", + "inputs": [{ + "name": "a", + "type": "uint256" + }], + "outputs": [{ + "name": "d", + "type": "uint256" + }] + }] + `) + ns.SetDescription("Will multiply `a` by 7 and return `a * 7`.") + ns.SetMethod("multiply") + + notice := ns.Parse() + + expected := "Will multiply 122 by 7 and return 854." + if notice != expected { + t.Errorf("incorrect notice. expected %v, got %v", expected, notice) + } else { + t.Logf("returned notice \"%v\"", notice) + } +} |