aboutsummaryrefslogtreecommitdiffstats
path: root/common/natspec
diff options
context:
space:
mode:
authorzsfelfoldi <zsfelfoldi@gmail.com>2015-04-17 19:46:38 +0800
committerzelig <viktor.tron@gmail.com>2015-04-20 03:57:49 +0800
commit929428d60216f31b2494df1ebf76d9be2a66028c (patch)
treed1f0ca664bf5f4428fdd4f6ad8f46fc16822eebe /common/natspec
parentb6fe9e0c838ced143cbdcc867b53ada2711b39da (diff)
downloaddexon-929428d60216f31b2494df1ebf76d9be2a66028c.tar
dexon-929428d60216f31b2494df1ebf76d9be2a66028c.tar.gz
dexon-929428d60216f31b2494df1ebf76d9be2a66028c.tar.bz2
dexon-929428d60216f31b2494df1ebf76d9be2a66028c.tar.lz
dexon-929428d60216f31b2494df1ebf76d9be2a66028c.tar.xz
dexon-929428d60216f31b2494df1ebf76d9be2a66028c.tar.zst
dexon-929428d60216f31b2494df1ebf76d9be2a66028c.zip
URLhint support for URLs longer than 32 bytes
Diffstat (limited to 'common/natspec')
-rw-r--r--common/natspec/natspec_e2e_test.go28
1 files changed, 23 insertions, 5 deletions
diff --git a/common/natspec/natspec_e2e_test.go b/common/natspec/natspec_e2e_test.go
index e8dba7d16..4e0f656f3 100644
--- a/common/natspec/natspec_e2e_test.go
+++ b/common/natspec/natspec_e2e_test.go
@@ -38,10 +38,12 @@ const (
testBalance = "1000000000000"
)
+const testFileName = "long_file_name_for_testing_registration_of_URLs_longer_than_32_bytes.content"
+
const testNotice = "Register key `utils.toHex(_key)` <- content `utils.toHex(_content)`"
const testExpNotice = "Register key 0xadd1a7d961cff0242089674ec2ef6fca671ab15e1fe80e38859fc815b98d88ab <- content 0xc00d5bcc872e17813df6ec5c646bb281a6e2d3b454c2c400c78192adf3344af9"
const testExpNotice2 = `About to submit transaction (NatSpec notice error "abi key %!x(MISSING) does not match any method %!v(MISSING)"): {"id":6,"jsonrpc":"2.0","method":"eth_transact","params":[{"from":"0xe273f01c99144c438695e10f24926dc1f9fbf62d","to":"0xb737b91f8e95cf756766fc7c62c9a8ff58470381","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":"0x8b839ad85686967a4f418eccc81962eaee314ac3","value":"100000000000","gas":"100000","gasPrice":"100000","data":"0xd66d6c10c00d5bcc872e17813df6ec5c646bb281a6e2d3b454c2c400c78192adf3344af900000000000000000000000066696c653a2f2f2f746573742e636f6e74656e74"}]}`
+const testExpNotice3 = `About to submit transaction (no NatSpec info found for contract): {"id":6,"jsonrpc":"2.0","method":"eth_transact","params":[{"from":"0xe273f01c99144c438695e10f24926dc1f9fbf62d","to":"0x8b839ad85686967a4f418eccc81962eaee314ac3","value":"100000000000","gas":"100000","gasPrice":"100000","data":"0x300a3bbfc00d5bcc872e17813df6ec5c646bb281a6e2d3b454c2c400c78192adf3344af900000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000"}]}`
const testUserDoc = `
{
@@ -244,8 +246,24 @@ func (self *testFrontend) applyTxs() {
func (self *testFrontend) registerURL(hash common.Hash, url string) {
hashHex := common.Bytes2Hex(hash[:])
- urlHex := common.Bytes2Hex([]byte(url))
- self.insertTx(self.coinbase, resolver.URLHintContractAddress, "register(uint256,uint256)", []string{hashHex, urlHex})
+ urlBytes := []byte(url)
+ var bb bool = true
+ var cnt byte
+ for bb {
+ bb = len(urlBytes) > 0
+ urlb := urlBytes
+ if len(urlb) > 32 {
+ urlb = urlb[:32]
+ }
+ urlHex := common.Bytes2Hex(urlb)
+ self.insertTx(self.coinbase, resolver.URLHintContractAddress, "register(uint256,uint8,uint256)", []string{hashHex, common.Bytes2Hex([]byte{cnt}), urlHex})
+ if len(urlBytes) > 32 {
+ urlBytes = urlBytes[32:]
+ } else {
+ urlBytes = nil
+ }
+ cnt++
+ }
}
func (self *testFrontend) setOwner() {
@@ -280,7 +298,7 @@ func TestNatspecE2E(t *testing.T) {
t.Logf("HashReg contract registered at %v", resolver.HashRegContractAddress)
tf.applyTxs()
- ioutil.WriteFile("/tmp/test.content", []byte(testDocs), os.ModePerm)
+ ioutil.WriteFile("/tmp/"+testFileName, []byte(testDocs), os.ModePerm)
dochash := common.BytesToHash(crypto.Sha3([]byte(testDocs)))
codehex := tf.xeth.CodeAt(resolver.HashRegContractAddress)
@@ -288,7 +306,7 @@ func TestNatspecE2E(t *testing.T) {
tf.setOwner()
tf.registerNatSpec(codehash, dochash)
- tf.registerURL(dochash, "file:///test.content")
+ tf.registerURL(dochash, "file:///"+testFileName)
tf.applyTxs()
chash, err := tf.testResolver().KeyToContentHash(codehash)