From 31df1cfe682eb5b1679a310b31d2c92567653d76 Mon Sep 17 00:00:00 2001 From: Elad Date: Tue, 19 Mar 2019 11:57:29 +0700 Subject: [PATCH] contracts/ens: address PR comments --- contracts/ens/cid.go | 9 +++++---- contracts/ens/cid_test.go | 10 ++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/contracts/ens/cid.go b/contracts/ens/cid.go index 6d39629ac5..fae9bfd0a1 100644 --- a/contracts/ens/cid.go +++ b/contracts/ens/cid.go @@ -70,7 +70,7 @@ func decodeEIP1577ContentHash(buf []byte) (storageNs, contentType, hashType, has } func extractContentHash(buf []byte) (common.Hash, error) { - storageNs, contentType, hashType, hashLength, hashBytes, err := decodeEIP1577ContentHash(buf) + storageNs, _ /*contentType*/, _ /* hashType*/, decodedHashLength, hashBytes, err := decodeEIP1577ContentHash(buf) if err != nil { return common.Hash{}, err @@ -80,15 +80,16 @@ func extractContentHash(buf []byte) (common.Hash, error) { return common.Hash{}, errors.New("unknown storage system") } - if contentType != swarmTypecode { + //todo: for the time being we implement loose enforcement for the EIP rules until ENS manager is updated + /*if contentType != swarmTypecode { return common.Hash{}, errors.New("unknown content type") } if hashType != swarmHashtype { return common.Hash{}, errors.New("unknown multihash type") - } + }*/ - if hashLength != hashLength { + if decodedHashLength != hashLength { return common.Hash{}, errors.New("odd hash length, swarm expects 32 bytes") } diff --git a/contracts/ens/cid_test.go b/contracts/ens/cid_test.go index 146495c99a..f2f1880846 100644 --- a/contracts/ens/cid_test.go +++ b/contracts/ens/cid_test.go @@ -94,6 +94,16 @@ func TestManualCidDecode(t *testing.T) { headerBytes: []byte{0xe3, 0x01, 0x70, 0x12, 0x20}, wantErr: true, }, + { + name: "loose values for swarm, todo remove, should not fail", + headerBytes: []byte{0xe4, 0x01, 0x70, 0x12, 0x20}, + wantErr: false, + }, + { + name: "loose values for swarm, todo remove, should not fail", + headerBytes: []byte{0xe4, 0x01, 0x99, 0x99, 0x20}, + wantErr: false, + }, } { t.Run(v.name, func(t *testing.T) { const eipHash = "29f2d17be6139079dc48696d1f582a8530eb9805b561eda517e22a892c7e3f1f"