Skip to content

Commit

Permalink
Challenge #1
Browse files Browse the repository at this point in the history
  • Loading branch information
eugenioclrc committed Jun 15, 2022
1 parent c70e9b9 commit 08367f1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 42 deletions.
12 changes: 1 addition & 11 deletions contracts/N1-SecureVault-easy.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//SPDX-License-Identifier: MIT
pragma solidity 0.8.0;
pragma solidity 0.8.11;

//import "hardhat/console.sol";

Expand Down Expand Up @@ -37,13 +37,6 @@ contract N1SecureVault {

uint256 _balance = address(this).balance;

/*console.log("------ recoverFunds secret check -------");
console.log(
"password to match ",
uint256(keccak256(abi.encodePacked(_secret, _balance)))
);
console.log("_password ", _password);*/

if (
_password == uint256(keccak256(abi.encodePacked(_secret, _balance)))
) {
Expand All @@ -65,7 +58,4 @@ contract N1SecureVault {
31337;
}

fallback() external {}

receive() external payable {}
}
25 changes: 0 additions & 25 deletions hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@ task("accounts", "Prints the list of accounts", async () => {
module.exports = {
solidity: {
compilers: [
{
version: '0.8.4',
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
{
version: '0.8.11',
settings: {
Expand All @@ -45,15 +36,6 @@ module.exports = {
},
},
},
{
version: '0.8.0',
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
{
version: '0.6.12',
settings: {
Expand All @@ -66,14 +48,7 @@ module.exports = {
],
},
networks: {
mumbai: {
url: `https://polygon-mumbai.g.alchemy.com/v2/${ALCHEMY_API_KEY_MUMBAI}`,
accounts: [TEAM_0],
},
hardhat: {
forking: {
url: `https://polygon-mumbai.g.alchemy.com/v2/${ALCHEMY_API_KEY_MUMBAI}`
}
},
},
};
Expand Down
20 changes: 14 additions & 6 deletions test/N1-SecureVault-easy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,23 @@ const CHALLENGES = require("../challenge-addresses.js")
const challengeAddress = CHALLENGES.N1SecureVault;

// run the test
// npx hardhat test ./test/N1-SecureVault-easy.js --network mumbai
// npx hardhat test ./test/N1-SecureVault-easy.js
describe("CTF #1 SecureVault", function () {
let challengeInstance, deployer;

before(async function () {
[deployer] = await ethers.getSigners();

const Challenge = await ethers.getContractFactory("N1SecureVault");
challengeInstance = await Challenge.deploy({ value: ethers.utils.parseEther('0.0001') });
await challengeInstance.deployed();
});

it("Should recover all funds", async function () {

// Your code goes here

const challengeInstance = await ethers.getContractAt(
"N1SecureVault",
challengeAddress
);
expect(await ethers.provider.getBalance(challengeInstance.address)).to.equal("0");

expect(await ethers.provider.getBalance(challengeInstance.address)).to.equal("0");
});
});

0 comments on commit 08367f1

Please sign in to comment.