Skip to content

Commit

Permalink
Ensured that MappedSinglyLinkedList#contains returns false for Sentinel
Browse files Browse the repository at this point in the history
  • Loading branch information
asselstine committed Aug 14, 2020
1 parent c1269c3 commit 30c0ada
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion contracts/utils/MappedSinglyLinkedList.sol
Expand Up @@ -57,7 +57,7 @@ library MappedSinglyLinkedList {
/// @param addr The address to check
/// @return True if the address is contained, false otherwise.
function contains(Mapping storage self, address addr) internal view returns (bool) {
return addr != address(0) && self.addressMap[addr] != address(0);
return addr != SENTINAL && addr != address(0) && self.addressMap[addr] != address(0);
}

/// @notice Returns an address array of all the addresses in this list
Expand Down
10 changes: 10 additions & 0 deletions test/MappedSinglyLinkedListExposed.test.js
Expand Up @@ -76,6 +76,16 @@ describe('MappedSinglyLinkedListExposed', function() {
})
})

describe('contains()', () => {
it('should return false for sentinel', async () => {
expect(await list.contains(SENTINAL)).to.be.false
})

it('should return false for the zero address', async () => {
expect(await list.contains(AddressZero)).to.be.false
})
})

describe('clearAll', () =>{
it('should clear the list', async () => {
await list.addAddress(wallet._address)
Expand Down

0 comments on commit 30c0ada

Please sign in to comment.