forked from hyperledger-cacti/cacti
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(quorum-connector): integration tests were failing
Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
- Loading branch information
Showing
10 changed files
with
229 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 23 additions & 3 deletions
26
...t/integration/plugin-ledger-connector-quorum/deploy-contract/deploy-contract-from-json.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,51 @@ | ||
// tslint:disable-next-line: no-var-requires | ||
const tap = require('tap'); | ||
import { PluginLedgerConnectorQuorum, PluginFactoryLedgerConnector } from '../../../../../main/typescript/public-api'; | ||
import { QuorumTestLedger } from '@hyperledger-labs/bif-test-tooling'; | ||
import { QuorumTestLedger, IQuorumGenesisOptions, IAccount } from '@hyperledger-labs/bif-test-tooling'; | ||
import HelloWorldContractJson from '../../../../solidity/hello-world-contract/HelloWorld.json'; | ||
import { Logger, LoggerProvider } from '@hyperledger-labs/bif-common'; | ||
|
||
const log: Logger = LoggerProvider.getOrCreate({ label: 'test-deploy-contract-from-json', level: 'trace' }) | ||
|
||
tap.test('deploys contract via .json file', async (assert: any) => { | ||
assert.plan(1); | ||
|
||
const quorumTestLedger = new QuorumTestLedger(); | ||
const quorumTestLedger = new QuorumTestLedger({ containerImageVersion: '1.0.0' }); | ||
await quorumTestLedger.start(); | ||
|
||
assert.tearDown(async () => { | ||
log.debug(`Starting teardown...`); | ||
await quorumTestLedger.stop(); | ||
log.debug(`Stopped container OK.`); | ||
await quorumTestLedger.destroy(); | ||
log.debug(`Destroyed container OK.`); | ||
}); | ||
|
||
// const rpcApiHttpHost: string = 'http://localhost:22000'; | ||
const rpcApiHttpHost = await quorumTestLedger.getRpcApiHttpHost(); | ||
const quorumGenesisOptions: IQuorumGenesisOptions = await quorumTestLedger.getGenesisJsObject(); | ||
assert.ok(quorumGenesisOptions); | ||
assert.ok(quorumGenesisOptions.alloc); | ||
|
||
const highNetWorthAccounts: string[] = Object.keys(quorumGenesisOptions.alloc).filter((address: string) => { | ||
const anAccount: IAccount = quorumGenesisOptions.alloc[address]; | ||
const balance: number = parseInt(anAccount.balance, 10); | ||
return balance > 10e7; | ||
}); | ||
const [firstHighNetWorthAccount] = highNetWorthAccounts; | ||
|
||
const factory = new PluginFactoryLedgerConnector(); | ||
const connector: PluginLedgerConnectorQuorum = await factory.create({ rpcApiHttpHost }); | ||
|
||
const options = { | ||
from: firstHighNetWorthAccount, // 0xed9d02e382b34818e88b88a309c7fe71e65f419d from the gensis json alloc property | ||
contractJsonArtifact: HelloWorldContractJson, | ||
// gas: 100000000000, | ||
// gasPrice: 0, | ||
}; | ||
|
||
const out = await connector.deployContract(options); | ||
assert.ok(out); | ||
|
||
assert.end(); | ||
log.debug('Assertion ended OK.'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
packages/bif-test-tooling/src/main/typescript/quorum/i-quorum-genesis-options.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
export interface IAccount { | ||
balance: string; | ||
} | ||
|
||
export interface IAllocations { | ||
[key: string]: IAccount; | ||
} | ||
|
||
export interface IConfig { | ||
homesteadBlock: number; | ||
byzantiumBlock: number; | ||
constantinopleBlock: number; | ||
chainId: number; | ||
eip150Block: number; | ||
eip155Block: number; | ||
eip150Hash: string; | ||
eip158Block: number; | ||
maxCodeSize: number; | ||
isQuorum: boolean; | ||
} | ||
|
||
export interface IQuorumGenesisOptions { | ||
alloc: IAllocations; | ||
coinbase: string; | ||
config: IConfig; | ||
difficulty: string; | ||
extraData: string; | ||
gasLimit: string; | ||
mixhash: string; | ||
nonce: string; | ||
parentHash: string; | ||
timestamp: string; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#!/usr/bin/env bash | ||
|
||
### | ||
### Continous Integration Shell Script | ||
### | ||
### Designed to be re-entrant on a local dev machine as well, not just on a | ||
### newly pulled up VM. | ||
### | ||
echo $BASH_VERSION | ||
|
||
STARTED_AT=`date +%s` | ||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
PROJECT_ROOT_DIR="$SCRIPT_DIR/.." | ||
|
||
function mainTask() | ||
{ | ||
set -euxo pipefail | ||
|
||
if ! [ -x "$(command -v lscpu)" ]; then | ||
echo 'lscpu is not installed, skipping...' | ||
else | ||
lscpu | ||
fi | ||
|
||
if ! [ -x "$(command -v lsmem)" ]; then | ||
echo 'lsmem is not installed, skipping...' | ||
else | ||
lsmem | ||
fi | ||
|
||
if ! [ -x "$(command -v smem)" ]; then | ||
echo 'smem is not installed, skipping...' | ||
else | ||
smem --abbreviate --totals --system | ||
fi | ||
|
||
# Travis does not have (nor need) nvm but CircleCI does have nvm and also | ||
# need it big time because their default Node version is 6.x... | ||
if [ "${CIRCLECI:-false}" = "true" ]; then | ||
set +x | ||
nvm install 10.19.0 | ||
nvm alias default 10.19.0 | ||
set -x | ||
fi | ||
|
||
docker --version | ||
docker-compose --version | ||
node --version | ||
npm --version | ||
java -version | ||
|
||
### COMMON | ||
cd $PROJECT_ROOT_DIR | ||
|
||
npm install | ||
npm run configure | ||
npm run test | ||
npm run test-integration | ||
|
||
ENDED_AT=`date +%s` | ||
runtime=$((ENDED_AT-STARTED_AT)) | ||
echo "$(date +%FT%T%z) [CI] SUCCESS - runtime=$runtime seconds." | ||
exit 0 | ||
} | ||
|
||
function onTaskFailure() | ||
{ | ||
set +eu # do not crash process upon individual command failures | ||
|
||
ENDED_AT=`date +%s` | ||
runtime=$((ENDED_AT-STARTED_AT)) | ||
echo "$(date +%FT%T%z) [CI] FAILURE - runtime=$runtime seconds." | ||
exit 1 | ||
} | ||
|
||
( | ||
mainTask | ||
) | ||
if [ $? -ne 0 ]; then | ||
onTaskFailure | ||
fi |