text: const VaultFactory = artifacts.require("./levels/VaultFactory.sol")
  const Vault = artifacts.require("./attacks/Vault.sol")
  const VaultAttack = artifacts.require("./attacks/VaultAttack.sol")
  
  const Ethernaut = artifacts.require("./Ethernaut.sol")
  
  import * as utils from "../utils/TestUtils"
  import expectThrow from "zeppelin-solidity/test/helpers/expectThrow"
  import toPromise from "zeppelin-solidity/test/helpers/toPromise"
  
  contract("Vault", function(accounts) {
  
    let ethernaut
    let level
    let owner = accounts[1]
    let player = accounts[0]
  
    before(async function() {
      ethernaut = await Ethernaut.new()
      level = await VaultFactory.new()
      await ethernaut.registerLevel(level.address)
    })
  
    it("should fail if the player did not solve the level", async function() {
      const instance = await utils.createLevelInstance(ethernaut, level.address, player, Vault)
  
      const completed = await utils.submitLevelInstance(
        ethernaut,
        level.address,
        instance.address,
        player
      )
  
      assert.isFalse(completed)
    })
  
  
    it("should allow the player to solve the level", async function() {
      const instance = await utils.createLevelInstance(ethernaut, level.address, player, Vault)
  
      const attacker = await VaultAttack.new()
      var password = web3.toAscii(web3.eth.getStorageAt(instance.address, 1))
  
      await attacker.attack(instance.address, password)
  
      const completed = await utils.submitLevelInstance(
        ethernaut,
        level.address,
        instance.address,
        player
      )
  
      assert.isTrue(completed)
    })
  
  })
  