mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-22 09:35:10 +00:00
Merge "[FAB-16147] Compilation and Lint Checks" into release-1.4
This commit is contained in:
commit
d26e27e0d1
13 changed files with 9617 additions and 47 deletions
21
Jenkinsfile
vendored
21
Jenkinsfile
vendored
|
|
@ -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
|
} // stages
|
||||||
post {
|
post {
|
||||||
always {
|
always {
|
||||||
|
|
|
||||||
4
chaincode/chaincode_example02/java/.gitignore
vendored
Normal file
4
chaincode/chaincode_example02/java/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
bin/
|
||||||
|
.classpath
|
||||||
|
.settings/
|
||||||
|
.gradle
|
||||||
17
commercial-paper/.build/makefile
Normal file
17
commercial-paper/.build/makefile
Normal 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
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "buy.js",
|
"main": "buy.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"lint": "eslint .",
|
||||||
"test": "rm -rf _idwallet && node addToWallet.js && node buy.js"
|
"test": "rm -rf _idwallet && node addToWallet.js && node buy.js"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
|
|
|
||||||
|
|
@ -26,76 +26,76 @@ const wallet = new FileSystemWallet('../identity/user/balaji/wallet');
|
||||||
// Main program function
|
// Main program function
|
||||||
async function main() {
|
async function main() {
|
||||||
|
|
||||||
// A gateway defines the peers used to access Fabric networks
|
// A gateway defines the peers used to access Fabric networks
|
||||||
const gateway = new Gateway();
|
const gateway = new Gateway();
|
||||||
|
|
||||||
// Main try/catch block
|
// Main try/catch block
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// Specify userName for network access
|
// Specify userName for network access
|
||||||
// const userName = 'isabella.issuer@magnetocorp.com';
|
// const userName = 'isabella.issuer@magnetocorp.com';
|
||||||
const userName = 'Admin@org1.example.com';
|
const userName = 'Admin@org1.example.com';
|
||||||
|
|
||||||
// Load connection profile; will be used to locate a gateway
|
// Load connection profile; will be used to locate a gateway
|
||||||
let connectionProfile = yaml.safeLoad(fs.readFileSync('../gateway/networkConnection.yaml', 'utf8'));
|
let connectionProfile = yaml.safeLoad(fs.readFileSync('../gateway/networkConnection.yaml', 'utf8'));
|
||||||
|
|
||||||
// Set connection options; identity and wallet
|
// Set connection options; identity and wallet
|
||||||
let connectionOptions = {
|
let connectionOptions = {
|
||||||
identity: userName,
|
identity: userName,
|
||||||
wallet: wallet,
|
wallet: wallet,
|
||||||
discovery: { enabled:false, asLocalhost: true }
|
discovery: { enabled:false, asLocalhost: true }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Connect to gateway using application specified parameters
|
// Connect to gateway using application specified parameters
|
||||||
console.log('Connect to Fabric gateway.');
|
console.log('Connect to Fabric gateway.');
|
||||||
|
|
||||||
await gateway.connect(connectionProfile, connectionOptions);
|
await gateway.connect(connectionProfile, connectionOptions);
|
||||||
|
|
||||||
// Access PaperNet network
|
// Access PaperNet network
|
||||||
console.log('Use network channel: mychannel.');
|
console.log('Use network channel: mychannel.');
|
||||||
|
|
||||||
const network = await gateway.getNetwork('mychannel');
|
const network = await gateway.getNetwork('mychannel');
|
||||||
|
|
||||||
// Get addressability to commercial paper contract
|
// Get addressability to commercial paper contract
|
||||||
console.log('Use org.papernet.commercialpaper smart 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
|
// redeem commercial paper
|
||||||
console.log('Submit commercial paper redeem transaction.');
|
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
|
// process response
|
||||||
console.log('Process redeem transaction 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(`${paper.issuer} commercial paper : ${paper.paperNumber} successfully redeemed with ${paper.owner}`);
|
||||||
console.log('Transaction complete.');
|
console.log('Transaction complete.');
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
||||||
console.log(`Error processing transaction. ${error}`);
|
console.log(`Error processing transaction. ${error}`);
|
||||||
console.log(error.stack);
|
console.log(error.stack);
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
|
|
||||||
// Disconnect from the gateway
|
// Disconnect from the gateway
|
||||||
console.log('Disconnect from Fabric gateway.')
|
console.log('Disconnect from Fabric gateway.');
|
||||||
gateway.disconnect();
|
gateway.disconnect();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
main().then(() => {
|
main().then(() => {
|
||||||
|
|
||||||
console.log('Redeem program complete.');
|
console.log('Redeem program complete.');
|
||||||
|
|
||||||
}).catch((e) => {
|
}).catch((e) => {
|
||||||
|
|
||||||
console.log('Redeem program exception.');
|
console.log('Redeem program exception.');
|
||||||
console.log(e);
|
console.log(e);
|
||||||
console.log(e.stack);
|
console.log(e.stack);
|
||||||
process.exit(-1);
|
process.exit(-1);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
.gradle/
|
.gradle/
|
||||||
build/
|
build/
|
||||||
bin/
|
bin/
|
||||||
|
.classpath
|
||||||
|
.settings/
|
||||||
|
|
@ -74,7 +74,7 @@ public class CommercialPaperContract implements ContractInterface {
|
||||||
|
|
||||||
// create an instance of the paper
|
// create an instance of the paper
|
||||||
CommercialPaper paper = CommercialPaper.createInstance(issuer, paperNumber, issueDateTime, maturityDateTime,
|
CommercialPaper paper = CommercialPaper.createInstance(issuer, paperNumber, issueDateTime, maturityDateTime,
|
||||||
faceValue,"");
|
faceValue,issuer,"");
|
||||||
|
|
||||||
// Smart contract, rather than paper, moves paper into ISSUED state
|
// Smart contract, rather than paper, moves paper into ISSUED state
|
||||||
paper.setIssued();
|
paper.setIssued();
|
||||||
|
|
|
||||||
1
commercial-paper/organization/digibank/contract/.gitignore
vendored
Normal file
1
commercial-paper/organization/digibank/contract/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
node_modules/
|
||||||
4755
commercial-paper/organization/digibank/contract/package-lock.json
generated
Normal file
4755
commercial-paper/organization/digibank/contract/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -4,6 +4,7 @@
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "issue.js",
|
"main": "issue.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"lint": "eslint .",
|
||||||
"test": "rm -rf _idwallet && node addToWallet.js && node issue.js"
|
"test": "rm -rf _idwallet && node addToWallet.js && node issue.js"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
|
|
|
||||||
1
commercial-paper/organization/magnetocorp/contract/.gitignore
vendored
Normal file
1
commercial-paper/organization/magnetocorp/contract/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
node_modules/
|
||||||
4755
commercial-paper/organization/magnetocorp/contract/package-lock.json
generated
Normal file
4755
commercial-paper/organization/magnetocorp/contract/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -30,6 +30,9 @@ Parse_Arguments() {
|
||||||
--fabcar_Tests)
|
--fabcar_Tests)
|
||||||
fabcar_Tests
|
fabcar_Tests
|
||||||
;;
|
;;
|
||||||
|
--commercialpaper_Tests)
|
||||||
|
commercialpaper_Tests
|
||||||
|
;;
|
||||||
--pull_Thirdparty_Images)
|
--pull_Thirdparty_Images)
|
||||||
pull_Thirdparty_Images
|
pull_Thirdparty_Images
|
||||||
;;
|
;;
|
||||||
|
|
@ -139,5 +142,14 @@ fabcar_Tests() {
|
||||||
echo "node version ------> $(node -v)"
|
echo "node version ------> $(node -v)"
|
||||||
echo "-----------> Execute FabCar Tests"
|
echo "-----------> Execute FabCar Tests"
|
||||||
./fabcar.sh
|
./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 $@
|
Parse_Arguments $@
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue