contracts/ens: adjust swarm multicodecs after pr merge

This commit is contained in:
Elad 2019-03-15 11:43:21 +07:00
parent 4a601337c0
commit 408bfd8c19
2 changed files with 10 additions and 10 deletions

View file

@ -30,8 +30,8 @@ const (
ns_ipfs = 0xe3 ns_ipfs = 0xe3
ns_swarm = 0xe4 ns_swarm = 0xe4
swarm_typecode = 0x99 //todo change swarm_typecode = 0xfa //swarm manifest
swarm_hashtype = 0x1b //todo change swarm_hashtype = 0xd6 // BMT
ipfs_hashtype = 0x12 ipfs_hashtype = 0x12
@ -82,11 +82,11 @@ func extractContentHash(buf []byte) (common.Hash, error) {
return common.Hash{}, errors.New("unknown storage system") return common.Hash{}, errors.New("unknown storage system")
} }
if contentType != swarm_typecode { //todo pending pr if contentType != swarm_typecode {
return common.Hash{}, errors.New("unknown content type") return common.Hash{}, errors.New("unknown content type")
} }
if hashType != swarm_hashtype { //todo: should be bmt if hashType != swarm_hashtype {
return common.Hash{}, errors.New("unknown multihash type") return common.Hash{}, errors.New("unknown multihash type")
} }
@ -106,8 +106,8 @@ func encodeSwarmHash(hash common.Hash) ([]byte, error) {
var headerBytes = []byte{ var headerBytes = []byte{
ns_swarm, //swarm namespace ns_swarm, //swarm namespace
cidv1, // CIDv1 cidv1, // CIDv1
swarm_typecode, // the swarm type-code swarm_typecode, // swarm hash
swarm_hashtype, // swarm hash type. todo BMT swarm_hashtype, // swarm bmt hash
hash_length, //hash length. 32 bytes hash_length, //hash length. 32 bytes
} }

View file

@ -78,22 +78,22 @@ func TestManualCidDecode(t *testing.T) {
}{ }{
{ {
name: "values correct, should not fail", name: "values correct, should not fail",
headerBytes: []byte{0xe4, 0x01, 0x99, 0x1b, 0x20}, headerBytes: []byte{0xe4, 0x01, 0xfa, 0xd6, 0x20},
fails: false, fails: false,
}, },
{ {
name: "cid version wrong, should fail", name: "cid version wrong, should fail",
headerBytes: []byte{0xe4, 0x00, 0x99, 0x1b, 0x20}, headerBytes: []byte{0xe4, 0x00, 0xfa, 0xd6, 0x20},
fails: true, fails: true,
}, },
{ {
name: "hash length wrong, should fail", name: "hash length wrong, should fail",
headerBytes: []byte{0xe4, 0x01, 0x99, 0x1b, 0x1f}, headerBytes: []byte{0xe4, 0x01, 0xfa, 0xd6, 0x1f},
fails: true, fails: true,
}, },
{ {
name: "values correct for ipfs, should fail", name: "values correct for ipfs, should fail",
headerBytes: []byte{0xe3, 0x01, 0x99, 0x1b, 0x20}, headerBytes: []byte{0xe3, 0x01, 0x70, 0x12, 0x20},
fails: true, fails: true,
}, },
} { } {