aboutsummaryrefslogtreecommitdiffstats
path: root/common/resolver
diff options
context:
space:
mode:
Diffstat (limited to 'common/resolver')
-rw-r--r--common/resolver/resolver.go1
-rw-r--r--common/resolver/resolver_test.go17
2 files changed, 10 insertions, 8 deletions
diff --git a/common/resolver/resolver.go b/common/resolver/resolver.go
index 9c71ac85f..2858a049d 100644
--- a/common/resolver/resolver.go
+++ b/common/resolver/resolver.go
@@ -81,5 +81,6 @@ func storageAddress(varidx uint32, key []byte) string {
data := make([]byte, 64)
binary.BigEndian.PutUint32(data[60:64], varidx)
copy(data[0:32], key[0:32])
+ //fmt.Printf("%x %v\n", key, common.Bytes2Hex(crypto.Sha3(data)))
return "0x" + common.Bytes2Hex(crypto.Sha3(data))
}
diff --git a/common/resolver/resolver_test.go b/common/resolver/resolver_test.go
index 17a1c4f94..7d570cbc6 100644
--- a/common/resolver/resolver_test.go
+++ b/common/resolver/resolver_test.go
@@ -14,7 +14,7 @@ type testBackend struct {
var (
text = "test"
- codehash = common.RightPadString("1234", 64)
+ codehash = "1234" //common.RightPadString("1234", 64)
hash = common.Bytes2Hex(crypto.Sha3([]byte(text)))
url = "bzz://bzzhash/my/path/contr.act"
)
@@ -23,13 +23,13 @@ func NewTestBackend() *testBackend {
self := &testBackend{}
self.contracts = make(map[string](map[string]string))
- self.contracts[HashRegContractAddress] = make(map[string]string)
- key := storageAddress(1, common.Hex2Bytes(codehash))
- self.contracts[HashRegContractAddress][key] = hash
+ self.contracts["0x"+HashRegContractAddress] = make(map[string]string)
+ key := storageAddress(1, common.Hex2BytesFixed(codehash, 32))
+ self.contracts["0x"+HashRegContractAddress][key] = "0x" + hash
- self.contracts[URLHintContractAddress] = make(map[string]string)
- key = storageAddress(1, common.Hex2Bytes(hash))
- self.contracts[URLHintContractAddress][key] = url
+ self.contracts["0x"+URLHintContractAddress] = make(map[string]string)
+ key = storageAddress(1, common.Hex2BytesFixed(hash, 32))
+ self.contracts["0x"+URLHintContractAddress][key] = "0x" + common.Bytes2Hex([]byte(url))
return self
}
@@ -48,6 +48,7 @@ func TestKeyToContentHash(t *testing.T) {
res := New(b, URLHintContractAddress, HashRegContractAddress)
chash := common.Hash{}
copy(chash[:], common.Hex2BytesFixed(codehash, 32))
+
got, err := res.KeyToContentHash(chash)
if err != nil {
t.Errorf("expected no error, got %v", err)
@@ -62,7 +63,7 @@ func TestContentHashToUrl(t *testing.T) {
b := NewTestBackend()
res := New(b, URLHintContractAddress, HashRegContractAddress)
chash := common.Hash{}
- copy(chash[:], common.Hex2Bytes(hash))
+ copy(chash[:], common.Hex2BytesFixed(hash, 32))
got, err := res.ContentHashToUrl(chash)
if err != nil {
t.Errorf("expected no error, got %v", err)