Skip to content

Commit

Permalink
Add rake task to run integration tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
tobyclemson committed Jan 20, 2021
1 parent 3f15345 commit dd86ccb
Show file tree
Hide file tree
Showing 14 changed files with 1,495 additions and 1,104 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ node_modules
/build
.etherlime-store
/localDeploy
/run

# Secrets
.secret
Expand All @@ -21,8 +22,8 @@ node_modules
*.ipr
.idea/

#Test Coverage
# Test Coverage
coverage*

#Personal Preferences
# Personal Preferences
.vscode
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
source 'https://rubygems.org'

gem 'rake', '~> 13.0'
gem 'random-port', '~> 0.5'
gem 'childprocess', '~> 4.0'
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
GEM
remote: https://rubygems.org/
specs:
childprocess (4.0.0)
rake (13.0.3)
random-port (0.5.1)

PLATFORMS
x86_64-darwin-19

DEPENDENCIES
childprocess (~> 4.0)
rake (~> 13.0)
random-port (~> 0.5)

BUNDLED WITH
2.2.6
53 changes: 53 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,61 @@
require 'random-port'
require 'childprocess'

task :default => :"contracts:compile"

namespace :ganache do
task :start, [:port] do |_, args|
port = args.port.to_s

puts "Starting ganache on port #{port}..."
process = ChildProcess.build(
'./node_modules/.bin/ganache-cli',
'--allowUnlimitedContractSize',
'-p', port)
# process.io.inherit!
process.leader = true
process.detach = true
process.start

FileUtils.mkdir_p('run/pid')
File.open("run/pid/ganache-#{port}.pid", "w") do |pidfile|
pidfile.write(process.pid)
end
end

task :stop, [:port] do |_, args|
port = args.port.to_s

puts "Stopping ganache on port #{port}..."
pid = File.read("run/pid/ganache-#{port}.pid").to_i

Process.kill('INT', pid)
File.unlink("run/pid/ganache-#{port}.pid")
end
end

namespace :contracts do
desc "Compile all contracts"
task :compile do
sh('npm run compile')
end
end

namespace :test do
desc "Run all contract integration tests"
task :integration do
RandomPort::Pool.new.acquire do |port|
begin
Rake::Task[:'ganache:start'].invoke(port)

puts "Running integration tests against node listening on #{port}..."
sh({
"HOST" => "127.0.0.1",
"PORT" => "#{port}"
}, 'npm run test:integration')
ensure
Rake::Task[:'ganache:stop'].invoke(port)
end
end
end
end
4 changes: 0 additions & 4 deletions migrations/2_deploy_contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,8 @@ module.exports = function(deployer, network, accounts) {
console.log("Boson Token Deposit Contract Address: ", BosonTokenDeposit.address);
})
})

});

})
})
});


};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"scripts": {
"compile": "truffle compile --all",
"test:unit": "truffle test",
"test:integration": "truffle test --network test",
"coverage": "node --max-old-space-size=4096 ./node_modules/.bin/truffle run coverage --network coverage",
"migrate-dev": "truffle migrate --network=rinkeby",
"verify-dev": "truffle run verify ERC1155ERC721 VoucherKernel Cashier BosonTokenPrice BosonTokenDeposit --network rinkeby"
Expand Down
Loading

0 comments on commit dd86ccb

Please sign in to comment.