lza_menace 2 years ago
parent 776f911ce1
commit 4eff231da3

@ -176,40 +176,6 @@ contract Main is Owned {
return mailbomb.bombsExploded();
}
/// Get N addresses from the leaderboard
/// @param _amount Amount of addresses to return
/// @return addresses List of addresses from the top N entries of leaderboard
function getLeaderboard(uint256 _amount) public view returns (address[] memory addresses) {
address[] memory addressList;
uint256 idx;
while (addressList.length < _amount) {
bool exists;
address a = leaderboard[leaderboardPointer - idx];
for (uint256 n; n < addressList.length; n++) {
if (addressList[n] == a) {
exists = true;
}
}
if (!exists) {
addressList[idx] = a;
idx++;
}
}
return addressList;
}
/// Get N kill amounts
/// @param addresses List of addresses to query kill counts for
/// @return amounts List of kill counts for each address in addresses
function getKillCounts(address[] memory addresses) public view returns (uint256[] memory amounts) {
uint256[] memory _amounts;
for (uint256 i; i < addresses.length; i++) {
address addr = addresses[i];
_amounts[i] = killCount[addr];
}
return _amounts;
}
// =========================================================================
// Tokens
// =========================================================================
@ -240,7 +206,7 @@ contract Main is Owned {
require(_amount <= unaboomer.totalSupply(), "not enough supply");
uint256 supply = unaboomer.totalSupply();
for (uint256 i; i < _amount; i++) {
uint256 randomBoomer = uint256(keccak256(abi.encodePacked(i, block.timestamp, msg.sender))) % supply;
uint256 randomBoomer = uint256(keccak256(abi.encodePacked(i, _amount, block.timestamp, msg.sender))) % supply;
bool dud = unaboomer.tokenDead(randomBoomer);
unaboomer.die(randomBoomer);
bool senderOwned = msg.sender == unaboomer.ownerOf(randomBoomer);

@ -51,6 +51,28 @@ contract UnaboomerTest is Test {
console.log(boomr.totalKillCount());
}
function testSendingBombs() public {
hoax(address(1));
main.radicalizeBoomers{value: .5 ether}(50);
hoax(address(2));
main.radicalizeBoomers{value: .1 ether}(10);
hoax(address(3));
main.radicalizeBoomers{value: .03 ether}(3);
hoax(address(4));
main.radicalizeBoomers{value: .15 ether}(15);
hoax(address(4));
main.sendBombs(10);
hoax(address(3));
main.sendBombs(6);
hoax(address(2));
main.sendBombs(10);
hoax(address(1));
main.sendBombs(25);
uint256 ptr = main.leaderboardPointer();
address leader = main.leaderboard(ptr);
uint256 killcount = main.killCount(leader);
}
function testKilling() public {
address t = address(1);
startHoax(t);

Loading…
Cancel
Save