contracts/ens: address PR comments

This commit is contained in:
Elad 2019-03-19 11:57:29 +07:00
parent 00fb2f345f
commit 31df1cfe68
2 changed files with 15 additions and 4 deletions

View file

@ -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")
}

View file

@ -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"