- Node v10.15.3
- Ganache CLI v6.4.3 (ganache-core: 2.5.5)
- Solidity 0.4.24
- Truffle v5.0.11 (core: 5.0.11)
- Solidity - 0.4.24 (solc-js)
- Web3.js v1.0.0-beta.37
- Downwload and unzip this repo to a folder on your machine.
- Open Terminal in this folder
- Run:
npm install
You will need specific configuration of ganache. So run:
ganache-cli -l 999999999999 -m "candy maplcake sugar puddi cream honey rich smooth crumble sweet treat" -e 10000 -a 30
This command will create the local test network with the following props:
- gas limit = 999999999999
- test accounts = 30
- ether on each test account = 10000
Specific configuration of test network is configured in truffle under the development_cli
alias.
So, you need to migrate the contract to this specific network. Hence, run in the project folder:
truffle migrate --network development_cli
Now server depends on truffle-contract
npm package, so you need to install it.
But if you just run npm install
inside ./src/server
folder, it will fail.
So first go ahead and open your node modules
cd ./node_modules
Then remove
rm -rf web3-providers-ws
Now, go up to you project folder again.
To start oracle server, you will have to change the folder in the Terminal first:
cd ./src/server
And install the truffle-contract
npm install
And start the server as normal Node.js process:
node server.js
Dapp that will allow you to interact with deployed contracts will be server for you on localhost:8000
.
In the project folder run:
npm run dapp
At this point you have set up the system locally, and you are good to go with tests and interactions with UI.
CAUTION! After you run automatic tests, please tear down the local system and set it up again for interaction with UI.
To set everything up again, run in the project folder
> ganache-cli -l 999999999999 -m "candy maplcake sugar puddi cream honey rich smooth crumble sweet treat" -e 10000 -a 30
> truffle migrate --network development_cli
> cd ./src/server
> node server.js
> cd ../..
> npm run dapp
Now open the locallhost:8000
in your browser.
IMPORTANT! You need to run the test files as described below. Otherwise, tests may fail due to bugs in the truffle/ganache.
Please, find yourself in the project folder again.
- Run unit tests for Flight Surety Data Contract
truffle test test/FlightSuretyDataTest.js --network development_cli
- Run unit tests for Flight Surety App Contract
truffle test test/FlightSuretyAppTest.js --network development_cli
- Run integration tests for Oracle App with FlightSurety
truffle test test/OracleTest.js --network development_cli
The Dapp has four sections: Contract, Airlines, Flights and Insurances.
Sections contain forms for the specific resource in the system.
Outcome of each form request outputs to Results section.
IMPORTANT!
When you try to search the Flight or Insurance in Get Flight
/ Get Insurance
forms, you need to use
the Id of the flight or insurance.
Ids are integers, starting with 1.
So if you have created two insurances in the network,
and you want to search for the first one, then use 1
as Insurance Id in the Get Insurance
form.
Same applies to Buy Insurance
. You need to use integer id of the flight. For first flight in the system the id will be 1
.