Class: EtherDev::TestCase

Inherits:
Minitest::Test
  • Object
show all
Defined in:
lib/ether_dev/test_case.rb

Instance Method Summary collapse

Instance Method Details

#setupObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ether_dev/test_case.rb', line 3

def setup
  @formatter = Ethereum::Formatter.new
  contract_name = self.class.name.dup
  contract_name.slice!("Test")

  @config = YAML.load(File.open("config/blockchain.yml"))[ENV["BLOCKCHAIN_ENV"] || "test"] || {}
  @client = Ethereum::HttpClient.create(@config["rpc"], true)

  @contract = Ethereum::Contract.create(file: "contracts/#{contract_name}.sol", client: @client)
  Eth.configure { |c| c.chain_id = @client.net_version["result"].to_i }

  @default_key = nil
   = nil

  if private_key = @config["account_key"]
    @default_key = Eth::Key.new priv: private_key
     = @default_key.address
  else
     = @client.
  end

  @contract.key = @default_key if @default_key.present?
  @contract.sender = 
end