[FAB-16147] Compilation and Lint Checks

Add in makefile to call the compilation and liniting
Only the applications and contracts currently
Testing needs to follow

Change-Id: I5604a71ea025cd01a1f27968122ea119697db7a5
Signed-off-by: Matthew B. White <whitemat@uk.ibm.com>
This commit is contained in:
Matthew B. White 2019-07-31 09:44:25 +01:00
parent 9040e28b55
commit 11d6ee14a9
13 changed files with 9617 additions and 47 deletions

21
Jenkinsfile vendored
View file

@ -136,6 +136,27 @@
}
}
}
// Run Commercial Paper tests
stage('Run Commercial Paper Tests') {
steps {
script {
// making the output color coded
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) {
try {
dir("$ROOTDIR/$BASE_DIR/scripts/ci_scripts") {
// Run fabcar tests
sh './ciScript.sh --commercialpaper_Tests'
}
}
catch (err) {
failure_stage = "commercialpaper_Tests"
currentBuild.result = 'FAILURE'
throw err
}
}
}
}
}
} // stages
post {
always {

View file

@ -0,0 +1,4 @@
bin/
.classpath
.settings/
.gradle

View file

@ -0,0 +1,17 @@
.PHONY: all
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
all: digibank magnetocorp
digibank:
cd ${ROOT_DIR}/../organization/$@/application-java; mvn clean compile package
cd ${ROOT_DIR}/../organization/$@/contract-java; ./gradlew clean build shadowJar
cd ${ROOT_DIR}/../organization/$@/application; npm install && npm run lint
cd ${ROOT_DIR}/../organization/$@/contract; npm install && npm run lint
magnetocorp:
cd ${ROOT_DIR}/../organization/$@/application-java; mvn clean compile package
cd ${ROOT_DIR}/../organization/$@/contract-java; ./gradlew clean build shadowJar
cd ${ROOT_DIR}/../organization/$@/application; npm install && npm run lint
cd ${ROOT_DIR}/../organization/$@/contract; npm install && npm run lint

View file

@ -4,6 +4,7 @@
"description": "",
"main": "buy.js",
"scripts": {
"lint": "eslint .",
"test": "rm -rf _idwallet && node addToWallet.js && node buy.js"
},
"keywords": [],

View file

@ -26,76 +26,76 @@ const wallet = new FileSystemWallet('../identity/user/balaji/wallet');
// Main program function
async function main() {
// A gateway defines the peers used to access Fabric networks
const gateway = new Gateway();
// A gateway defines the peers used to access Fabric networks
const gateway = new Gateway();
// Main try/catch block
try {
// Main try/catch block
try {
// Specify userName for network access
// const userName = 'isabella.issuer@magnetocorp.com';
const userName = 'Admin@org1.example.com';
// Specify userName for network access
// const userName = 'isabella.issuer@magnetocorp.com';
const userName = 'Admin@org1.example.com';
// Load connection profile; will be used to locate a gateway
let connectionProfile = yaml.safeLoad(fs.readFileSync('../gateway/networkConnection.yaml', 'utf8'));
// Load connection profile; will be used to locate a gateway
let connectionProfile = yaml.safeLoad(fs.readFileSync('../gateway/networkConnection.yaml', 'utf8'));
// Set connection options; identity and wallet
let connectionOptions = {
identity: userName,
wallet: wallet,
discovery: { enabled:false, asLocalhost: true }
};
// Set connection options; identity and wallet
let connectionOptions = {
identity: userName,
wallet: wallet,
discovery: { enabled:false, asLocalhost: true }
};
// Connect to gateway using application specified parameters
console.log('Connect to Fabric gateway.');
// Connect to gateway using application specified parameters
console.log('Connect to Fabric gateway.');
await gateway.connect(connectionProfile, connectionOptions);
await gateway.connect(connectionProfile, connectionOptions);
// Access PaperNet network
console.log('Use network channel: mychannel.');
// Access PaperNet network
console.log('Use network channel: mychannel.');
const network = await gateway.getNetwork('mychannel');
const network = await gateway.getNetwork('mychannel');
// Get addressability to commercial paper contract
console.log('Use org.papernet.commercialpaper smart contract.');
// Get addressability to commercial paper contract
console.log('Use org.papernet.commercialpaper smart contract.');
const contract = await network.getContract('papercontract', 'org.papernet.commercialpaper');
const contract = await network.getContract('papercontract', 'org.papernet.commercialpaper');
// redeem commercial paper
console.log('Submit commercial paper redeem transaction.');
// redeem commercial paper
console.log('Submit commercial paper redeem transaction.');
const redeemResponse = await contract.submitTransaction('redeem', 'MagnetoCorp', '00001', 'DigiBank', '2020-11-30');
const redeemResponse = await contract.submitTransaction('redeem', 'MagnetoCorp', '00001', 'DigiBank', '2020-11-30');
// process response
console.log('Process redeem transaction response.');
// process response
console.log('Process redeem transaction response.');
let paper = CommercialPaper.fromBuffer(redeemResponse);
let paper = CommercialPaper.fromBuffer(redeemResponse);
console.log(`${paper.issuer} commercial paper : ${paper.paperNumber} successfully redeemed with ${paper.owner}`);
console.log('Transaction complete.');
console.log(`${paper.issuer} commercial paper : ${paper.paperNumber} successfully redeemed with ${paper.owner}`);
console.log('Transaction complete.');
} catch (error) {
} catch (error) {
console.log(`Error processing transaction. ${error}`);
console.log(error.stack);
console.log(`Error processing transaction. ${error}`);
console.log(error.stack);
} finally {
} finally {
// Disconnect from the gateway
console.log('Disconnect from Fabric gateway.')
gateway.disconnect();
// Disconnect from the gateway
console.log('Disconnect from Fabric gateway.');
gateway.disconnect();
}
}
}
main().then(() => {
console.log('Redeem program complete.');
console.log('Redeem program complete.');
}).catch((e) => {
console.log('Redeem program exception.');
console.log(e);
console.log(e.stack);
process.exit(-1);
console.log('Redeem program exception.');
console.log(e);
console.log(e.stack);
process.exit(-1);
});

View file

@ -1,3 +1,5 @@
.gradle/
build/
bin/
bin/
.classpath
.settings/

View file

@ -74,7 +74,7 @@ public class CommercialPaperContract implements ContractInterface {
// create an instance of the paper
CommercialPaper paper = CommercialPaper.createInstance(issuer, paperNumber, issueDateTime, maturityDateTime,
faceValue,"");
faceValue,issuer,"");
// Smart contract, rather than paper, moves paper into ISSUED state
paper.setIssued();

View file

@ -0,0 +1 @@
node_modules/

File diff suppressed because it is too large Load diff

View file

@ -4,6 +4,7 @@
"description": "",
"main": "issue.js",
"scripts": {
"lint": "eslint .",
"test": "rm -rf _idwallet && node addToWallet.js && node issue.js"
},
"keywords": [],

View file

@ -0,0 +1 @@
node_modules/

File diff suppressed because it is too large Load diff

View file

@ -30,6 +30,9 @@ Parse_Arguments() {
--fabcar_Tests)
fabcar_Tests
;;
--commercialpaper_Tests)
commercialpaper_Tests
;;
--pull_Thirdparty_Images)
pull_Thirdparty_Images
;;
@ -139,5 +142,14 @@ fabcar_Tests() {
echo "node version ------> $(node -v)"
echo "-----------> Execute FabCar Tests"
./fabcar.sh
echo "Also running the compilation and lint tests of CommercialPaper"
make -f ../../commercial-paper/.build/makefile
}
# run commercial paper tests
commercialpaper_Tests() {
echo
echo "-----------> Execute Commercial Paper Tests"
make -f ../../commercial-paper/.build/makefile
}
Parse_Arguments $@