Skip to content

Commit

Permalink
Add final tests for delegation
Browse files Browse the repository at this point in the history
  • Loading branch information
XertroV committed Jul 31, 2018
1 parent 24d1f5f commit bca4c19
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion contracts/Ed25519Delegation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ contract UnsafeEd25519SelfDelegation {
}

// Get all recorded delegations between a start date and end date
function getAllForPubKeyBetween (bytes32 pubKey, uint startDate, uint endDate) public view returns (
function getAllForPubKeyBetween(bytes32 pubKey, uint startDate, uint endDate) public view returns (
bytes32[] memory dlgtRequests,
bytes32[] memory sig1s,
bytes32[] memory sig2s,
Expand Down
10 changes: 10 additions & 0 deletions test/ed25519Delegation.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,17 @@ const testDelegation = async ({selfDelegation, doLog, owner, accounts}) => {
assert.deepEqual(d1Dlgtions.slice(0,3), expectedD1, 'dlgation 1 match, sans timestamp')

// do another delegation
const d2 = mkDelegation(d1.toAddr, w3.utils.genRandomHex(3), d1.kp)
const d2Dlgtions = await selfDelegation.getAllForPubKey(d2.data[1])
const expectedD2 = R.compose(R.map(R.concat), R.zip)([[d2.data[0]], [d2.data[2][0]], [d2.data[2][1]]])

assert.equal(await selfDelegation.dLogN(), 1, '1 pk - dlgtion')
assert.equal(await selfDelegation.nDelegations(d1.data[1]), 2, '2 dlgtion for pk')
assert.equal(await selfDelegation.nAddressLog(), 1, '1 addr - dlgtion')
assert.deepEqual(d2Dlgtions.slice(0,3), expectedD2, 'dlgation 2 match, sans timestamp')

// do test with silly time range to get 0 results
assert.deepEqual(await selfDelegation.getAllForPubKeyBetween(d2.data[1], 0, 1), [[],[],[],[]], 'dlgation get with silly timestamps returns empty')
}


Expand Down

0 comments on commit bca4c19

Please sign in to comment.