UNPKG

xek-sdk

Version:

SDK for katana blockchain

55 lines (44 loc) 2.25 kB
'use strict'; const assert = require('assert'); const config = require('./config-test'); function sleep(ms){ return new Promise(resolve=>{ setTimeout(resolve,ms) }) } describe("3. Test add owner function",async function(){ it("True case", async function(){ let required = 2; // new contract let resultDeploy = await config.myContract.deploy(config.owner1, config.passphraseOwner1, [[config.owner1,config.owner2], required]); console.log('resultDeploy:', resultDeploy); assert.equal(resultDeploy.success,true); assert.notEqual(resultDeploy.data, null); let contractAddr = resultDeploy.data; console.log('contractAddr:', contractAddr); // await sleep(1000); // // data add owner function // let dataAddOwner= config.myContract.getMethod("addOwner",["9C9FAE22545172DADC668DA7F60E9CB617EE969B"]); // // data and broastcast tx of add owner function // let dataSubmitTx = config.myContract.getMethod("submitTransaction",[contractAddr, 0, dataAddOwner]); // let res = await config.myContract.broadcastBurrowTx("submitTransaction", config.owner1, contractAddr, config.passphraseOwner1, dataSubmitTx); // console.log('res:', res); // assert.equal(res.success, true); // assert.notDeepEqual(res.data, null); // await sleep(1000); // // confirm tx // let dataConfirmTx = config.myContract.getMethod("confirmTransaction",[0]); // res = await config.myContract.broadcastBurrowTx("confirmTransaction", config.owner2, contractAddr, config.passphraseOwner2, dataConfirmTx); // console.log('res2:', res); // assert.equal(res.success, true); // assert.notDeepEqual(res.data, null); // await sleep(1000); // get owner let dataGetOwner = config.myContract.getMethod("getOwners",[]); let getOwner = await config.myContract.broadcastBurrowTx("getOwners",config.owner1,contractAddr,config.passphraseOwner1,dataGetOwner); console.log('getOwner:', getOwner); assert.equal(getOwner.length, 3); let owners = [getOwner[0].toUpperCase().slice(2),getOwner[1].toUpperCase().slice(2),getOwner[2].toUpperCase().slice(2)]; assert.deepEqual(owners,[config.owner1,config.owner2,'9C9FAE22545172DADC668DA7F60E9CB617EE969B']); }); });