aboutsummaryrefslogtreecommitdiffstats
path: root/common/natspec/natspec_e2e_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'common/natspec/natspec_e2e_test.go')
-rw-r--r--common/natspec/natspec_e2e_test.go34
1 files changed, 21 insertions, 13 deletions
diff --git a/common/natspec/natspec_e2e_test.go b/common/natspec/natspec_e2e_test.go
index aff094d1d..a99ba7fcd 100644
--- a/common/natspec/natspec_e2e_test.go
+++ b/common/natspec/natspec_e2e_test.go
@@ -32,7 +32,9 @@ type testFrontend struct {
}
const testNotice = "Register key `_key` <- content `_content`"
-const testExpNotice = "Register key 8.9477152217924674838424037953991966239322087453347756267410168184682657981552e+76 <- content 2.9345842665291639932787537650068479186757226656217642728276414736233000517704e+76"
+const testExpNotice = "Register key 7.8620552293692941353904828453472309202657763561546399188096247518683806402731e+76 <- content 2.9345842665291639932787537650068479186757226656217642728276414736233000517704e+76"
+const testExpNotice2 = `About to submit transaction (couldn't create NatSpec notice): {"id":6,"jsonrpc":"2.0","method":"eth_transact","params":[{"from":"0xe273f01c99144c438695e10f24926dc1f9fbf62d","to":"0x0000000000000000000000000000000000000009","value":"100000000000","gas":"100000","gasPrice":"100000","data":"0x31e12c20"}]}`
+const testExpNotice3 = `About to submit transaction (no NatSpec info found for contract): {"id":6,"jsonrpc":"2.0","method":"eth_transact","params":[{"from":"0xe273f01c99144c438695e10f24926dc1f9fbf62d","to":"0x0000000000000000000000000000000000000008","value":"100000000000","gas":"100000","gasPrice":"100000","data":"0xd66d6c1040e128891caf6033850eb422796ecd92ca7393052020b64455cf8ac00c4ac04800000000000000000000000066696c653a2f2f2f746573742e636f6e74656e74"}]}`
const testUserDoc = `
{
@@ -89,15 +91,7 @@ func (f *testFrontend) ConfirmTransaction(tx string) bool {
if err != nil {
f.t.Errorf("Error creating DocServer: %v", err)
}
- nat, err2 := natspec.New(f.xeth, tx, ds)
- if err2 == nil {
- f.lastConfirm, err = nat.Notice()
- if err != nil {
- f.t.Errorf("Notice error: %v", err)
- }
- } else {
- f.t.Errorf("Error creating NatSpec: %v", err2)
- }
+ f.lastConfirm = natspec.GetNotice(f.xeth, tx, ds)
}
return true
}
@@ -270,7 +264,7 @@ func TestNatspecE2E(t *testing.T) {
dochash := common.BytesToHash(crypto.Sha3([]byte(testDocs)))
codehex := tf.xeth.CodeAt(core.ContractAddrHashReg)
- codehash := common.BytesToHash(crypto.Sha3(common.Hex2Bytes(codehex)))
+ codehash := common.BytesToHash(crypto.Sha3(common.Hex2Bytes(codehex[2:])))
tf.setOwner()
tf.registerNatSpec(codehash, dochash)
@@ -288,12 +282,26 @@ func TestNatspecE2E(t *testing.T) {
}
t.Logf("url = %v err = %v", url, err2)
+ // NatSpec info for register method of HashReg contract installed
+ // now using the same transactions to check confirm messages
+
tf.makeNatSpec = true
- tf.registerNatSpec(codehash, dochash) // call again just to get a confirm message
+ tf.registerNatSpec(codehash, dochash)
t.Logf("Confirm message: %v\n", tf.lastConfirm)
-
if tf.lastConfirm != testExpNotice {
t.Errorf("Wrong confirm message, expected '%v', got '%v'", testExpNotice, tf.lastConfirm)
}
+ tf.setOwner()
+ t.Logf("Confirm message for unknown method: %v\n", tf.lastConfirm)
+ if tf.lastConfirm != testExpNotice2 {
+ t.Errorf("Wrong confirm message, expected '%v', got '%v'", testExpNotice2, tf.lastConfirm)
+ }
+
+ tf.registerURL(dochash, "file:///test.content")
+ t.Logf("Confirm message for unknown contract: %v\n", tf.lastConfirm)
+ if tf.lastConfirm != testExpNotice3 {
+ t.Errorf("Wrong confirm message, expected '%v', got '%v'", testExpNotice3, tf.lastConfirm)
+ }
+
}