forked from OpenZeppelin/ethernaut
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Fallout.test.js
51 lines (44 loc) · 1.3 KB
/
Fallout.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const FalloutFactory = artifacts.require('./levels/FalloutFactory.sol');
const Fallout = artifacts.require('./attacks/Fallout.sol');
const Ethernaut = artifacts.require('./Ethernaut.sol');
const {
BN,
constants,
expectEvent,
expectRevert,
} = require('openzeppelin-test-helpers');
const utils = require('../utils/TestUtils');
const { ethers, upgrades } = require('hardhat');
contract('Fallout', function (accounts) {
let ethernaut;
let level;
let owner = accounts[1];
let player = accounts[0];
let statproxy;
beforeEach(async function () {
ethernaut = await utils.getEthernautWithStatsProxy();
level = await FalloutFactory.new();
await ethernaut.registerLevel(level.address);
//console.log(ethernaut.address, level.address)
});
it('should allow the player to solve the level', async function () {
const instance = await utils.createLevelInstance(
ethernaut,
level.address,
player,
Fallout,
{ from: player }
);
assert.equal(await instance.owner(), 0x0);
await instance.Fal1out();
assert.equal(await instance.owner(), player);
// Factory check
const ethCompleted = await utils.submitLevelInstance(
ethernaut,
level.address,
instance.address,
player
);
assert.equal(ethCompleted, true);
});
});