github.com/igggame/nebulas-go@v2.1.0+incompatible/nf/nvm/test/inner_call_tests/caller.js (about) 1 "use strict"; 2 3 function Contract() {} 4 // deploy this contract in or after 1.1.0 5 Contract.prototype = { 6 init: function () { 7 // 8 }, 9 10 testInnerCall: function(address, expectResult) { 11 var funcs = { 12 supportInnerCall: function() { 13 14 } 15 } 16 17 var c = new Blockchain.Contract(address, funcs); 18 19 var actual = c.value(0).call("supportInnerCall"); 20 if (expectResult != actual) { 21 throw new Error("expect: " + expectResult + ", actual: " + actual); 22 } 23 }, 24 25 testRandom: function(address, expRandseed, expBlockseed, expRandseedInCaller, expBlockseedInCaller) { 26 var funcs = { 27 supportRandom: function() { 28 29 } 30 } 31 32 var c = new Blockchain.Contract(address, funcs); 33 34 var actual = c.value(0).call("supportRandom"); 35 console.error("actual:", actual); 36 if (expRandseed != actual.randseed) { 37 throw new Error("expRandseed: " + expRandseed + ", actual: " + actual.randseed); 38 } 39 if (expBlockseed != actual.blockseed) { 40 throw new Error("expBlockseed: " + expBlockseed + ", actual: " + actual.blockseed); 41 } 42 if (expRandseedInCaller != (typeof(Math.random.seed) === 'function')) { 43 throw new Error("expect: Math.random.seed exists in caller ? " + expRandseedInCaller); 44 } 45 if (expBlockseedInCaller != Blockchain.block.seed != '') { 46 throw new Error("expect: Blockchain.block.seed=" + expBlockseedInCaller); 47 } 48 } 49 }; 50 51 module.exports = Contract;