github.com/muhammedhassanm/blockchain@v0.0.0-20200120143007-697261defd4d/blockapps-ba-master/server/dapp/dapp.deploy.js (about) 1 require('co-mocha'); 2 const ba = require('blockapps-rest'); 3 const rest = ba.rest; 4 const common = ba.common; 5 const config = common.config; 6 const util = common.util; 7 const should = common.should; 8 const assert = common.assert; 9 const expect = common.expect; 10 const Promise = common.Promise; 11 12 // --------------------------------------------------- 13 // deploy the projects contracts 14 // --------------------------------------------------- 15 16 const dappJs = require('./dapp'); 17 18 describe('Supply Chain Demo App - deploy contracts', function () { 19 this.timeout(900 * 1000); 20 21 assert.isDefined(config.dataFilename, 'Data argument missing. Set in config, or use --data <path>'); 22 23 const adminName = util.uid('Admin'); // FIXME 24 const adminPassword = '7890'; // FIXME 25 26 // uploading the admin contract and dependencies 27 it('should upload the contracts', function* () { 28 // get the dapp 29 const admin = yield rest.createUser(adminName, adminPassword); 30 // wait for the transaction to be added to blockchain 31 do { 32 yield new Promise(resolve => setTimeout(resolve, 1000)) 33 } while ((yield rest.getBalance(admin.address)) < 1); 34 const dapp = yield dappJs.uploadContract(admin, config.libPath); 35 const deployment = yield dapp.deploy(config.dataFilename, config.deployFilename); 36 }); 37 });