mirror of
git://holbrook.no/eth-address-index
synced 2024-11-30 03:46:46 +01:00
Fix bug overwriting content when more than one declaration
This commit is contained in:
parent
3dd286285c
commit
d5de82198c
File diff suppressed because one or more lines are too long
@ -1,2 +1,2 @@
|
||||
confini~=0.5.1
|
||||
chainlib-eth~=0.0.10
|
||||
confini~=0.5.2
|
||||
chainlib-eth~=0.0.22
|
||||
|
@ -1,6 +1,6 @@
|
||||
[metadata]
|
||||
name = eth-address-index
|
||||
version = 0.2.4
|
||||
version = 0.2.5
|
||||
description = Signed metadata declarations for ethereum addresses
|
||||
author = Louis Holbrook
|
||||
author_email = dev@holbrook.no
|
||||
@ -38,3 +38,4 @@ packages =
|
||||
console_scripts =
|
||||
eth-address-declarator-deploy = eth_address_declarator.runnable.deploy:main
|
||||
eth-address-declarator-add = eth_address_declarator.runnable.add:main
|
||||
eth-address-declarator-view = eth_address_declarator.runnable.view:main
|
||||
|
@ -1,4 +1,4 @@
|
||||
eth-tester==0.5.0b3
|
||||
py-evm==0.3.0a20
|
||||
eth-accounts-index>=0.1.2a3,<0.2.0
|
||||
eth_erc20>=0.1.2a3,<=0.2.0
|
||||
eth-accounts-index~=0.1.3
|
||||
eth_erc20~=0.1.5
|
||||
|
@ -183,5 +183,56 @@ class TestAddressDeclarator(TestAddressDeclaratorBase):
|
||||
self.assertEqual(c.parse_declaration_address_at(r), strip_0x(self.accounts[2]))
|
||||
|
||||
|
||||
def test_three_first(self):
|
||||
d = []
|
||||
for i in range(3):
|
||||
d.append(add_0x(os.urandom(32).hex()))
|
||||
|
||||
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||
c = Declarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||
|
||||
for proof in d:
|
||||
(tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[0], self.foo_token_address, proof)
|
||||
self.rpc.do(o)
|
||||
|
||||
o = c.declarator_count(self.address, self.foo_token_address, sender_address=self.accounts[0])
|
||||
r = self.rpc.do(o)
|
||||
self.assertEqual(c.parse_declarator_count(r), 1)
|
||||
|
||||
o = c.declaration(self.address, self.accounts[0], self.foo_token_address, sender_address=self.accounts[0])
|
||||
r = self.rpc.do(o)
|
||||
proofs = c.parse_declaration(r)
|
||||
self.assertEqual(len(proofs), 3)
|
||||
|
||||
for i in range(3):
|
||||
self.assertEqual(proofs[i], strip_0x(d[i]))
|
||||
|
||||
|
||||
def test_three_first_different(self):
|
||||
d = []
|
||||
a = []
|
||||
for i in range(3):
|
||||
d.append(add_0x(os.urandom(32).hex()))
|
||||
a.append(add_0x(os.urandom(20).hex()))
|
||||
|
||||
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
||||
c = Declarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
||||
|
||||
for i in range(3):
|
||||
(tx_hash_hex, o) = c.add_declaration(self.address, self.accounts[0], a[i], d[i])
|
||||
self.rpc.do(o)
|
||||
|
||||
for i in range(3):
|
||||
o = c.declarator_count(self.address, a[i], sender_address=self.accounts[0])
|
||||
r = self.rpc.do(o)
|
||||
self.assertEqual(c.parse_declarator_count(r), 1)
|
||||
|
||||
o = c.declaration(self.address, self.accounts[0], a[i], sender_address=self.accounts[0])
|
||||
r = self.rpc.do(o)
|
||||
proofs = c.parse_declaration(r)
|
||||
self.assertEqual(len(proofs), 1)
|
||||
self.assertEqual(proofs[0], strip_0x(d[i]))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
File diff suppressed because one or more lines are too long
@ -20,20 +20,21 @@ contract AddressDeclarator {
|
||||
contents[contents.length-1].push(blockhash(block.number));
|
||||
|
||||
addDeclaration(msg.sender, _initialDescription);
|
||||
|
||||
}
|
||||
|
||||
function toReference(address _declarator, address _subject) private pure returns ( bytes32 ) {
|
||||
bytes32 k;
|
||||
bytes memory signMaterial = new bytes(40);
|
||||
bytes memory addrMaterial = new bytes(40);
|
||||
bytes memory addrBytes = abi.encodePacked(_declarator);
|
||||
for (uint256 i = 0; i < 20; i++) {
|
||||
signMaterial[i] = addrBytes[i];
|
||||
addrMaterial[i] = addrBytes[i];
|
||||
}
|
||||
addrBytes = abi.encodePacked(_subject);
|
||||
for (uint256 i = 0; i < 20; i++) {
|
||||
signMaterial[i+20] = addrBytes[i];
|
||||
addrMaterial[i+20] = addrBytes[i];
|
||||
}
|
||||
k = sha256(signMaterial);
|
||||
k = sha256(addrMaterial);
|
||||
return k;
|
||||
}
|
||||
|
||||
@ -77,9 +78,9 @@ contract AddressDeclarator {
|
||||
declarator[_subject].push(tx.origin);
|
||||
contents.push(declarationContents);
|
||||
declarationIndex[tx.origin].push(_subject);
|
||||
idx = contents.length-1;
|
||||
}
|
||||
|
||||
idx = contents.length-1;
|
||||
declarationContentIndex[ks[0]] = idx;
|
||||
contents[idx].push(_proof);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user