aboutsummaryrefslogtreecommitdiffstats
path: root/ethutil/natspec/natspec_test.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-03-10 00:55:01 +0800
committerobscuren <geffobscura@gmail.com>2015-03-10 00:55:01 +0800
commit8560004f380dc688a1171ad5aeffa593aae41193 (patch)
treefea395acf042b51e97a86e2c4cbcf8c16b2912b7 /ethutil/natspec/natspec_test.go
parent9723191b19f6ddc12f0c3376ede7529b2d72e6a2 (diff)
parent676a0de58d3d7c508b0eeeff192d2095a46f7382 (diff)
downloaddexon-8560004f380dc688a1171ad5aeffa593aae41193.tar.gz
dexon-8560004f380dc688a1171ad5aeffa593aae41193.tar.zst
dexon-8560004f380dc688a1171ad5aeffa593aae41193.zip
wip
Diffstat (limited to 'ethutil/natspec/natspec_test.go')
-rw-r--r--ethutil/natspec/natspec_test.go51
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)
+ }
+}