Skip to content

Commit

Permalink
nebtestkit: update test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Silentttttt committed Jun 14, 2018
1 parent a1e3c2a commit 27d5226
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 41 deletions.
2 changes: 1 addition & 1 deletion nebtestkit/cases/contract/contract.deploy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1291,7 +1291,7 @@ describe('contract deploy', function () {
status: 0,
fromBalanceAfterTx: '9999999976573000000',
toBalanceAfterTx: '0',
transferReward: '23437000000'
transferReward: '23427000000'
};
prepare((err) => {
if (err) {
Expand Down
78 changes: 39 additions & 39 deletions nebtestkit/cases/contract/contract.features.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,19 @@ describe('test transfer from contract', function () {
};
neb.api.call(sourceAccount.getAddressString(), contractAddress, Unit.nasToBasic(10), nonce, 200000, 1000000, contract).then(function(resp){
console.log(JSON.stringify(resp));
expect(resp.execute_err).to.be.equal("Call: getAccountState: invalid address");
expect(resp.execute_err).to.be.equal("Call: Blockchain.getAccountState(), parse address failed");
done();
}).catch(function(err) {
console.log(err);
done(err);
});
});

it ('3. test feature getPreBlockHash 1/5[distance is 1]', function (done) {
var distance = 1;
it ('3. test feature getPreBlockHash 1/5[offset is 1]', function (done) {
var offset = 1;
var contract = {
'function': 'testGetPreBlockHash',
"args": '[' + distance + ']',
"args": '[' + offset + ']',
};
var hash;
var height;
Expand All @@ -158,7 +158,7 @@ describe('test transfer from contract', function () {
var result = JSON.parse(resp.result);
hash = result.hash;
height = result.height;
return neb.api.getBlockByHeight(height - distance);
return neb.api.getBlockByHeight(height - offset);
}).then(function(resp) {
// console.log(JSON.stringify(resp));
expect(resp.hash).to.be.equal(hash);
Expand All @@ -169,11 +169,11 @@ describe('test transfer from contract', function () {
});
});

it ('4. test feature getPreBlockHash 2/5[distance is "1"]', function (done) {
var distance = 1;
it ('4. test feature getPreBlockHash 2/5[offset is "1"]', function (done) {
var offset = 1;
var contract = {
'function': 'testGetPreBlockHash',
"args": "[\"" + distance + "\"]",
"args": "[\"" + offset + "\"]",
};
var hash;
var height;
Expand All @@ -182,7 +182,7 @@ describe('test transfer from contract', function () {
var result = JSON.parse(resp.result);
hash = result.hash;
height = result.height;
return neb.api.getBlockByHeight(height - distance);
return neb.api.getBlockByHeight(height - offset);
}).then(function(resp) {
// console.log(JSON.stringify(resp));
expect(resp.hash).to.be.equal(hash);
Expand All @@ -193,43 +193,43 @@ describe('test transfer from contract', function () {
});
});

it ('5. test feature getPreBlockHash 3/5[distance is "#1"]', function (done) {
var distance = "#1";
it ('5. test feature getPreBlockHash 3/5[offset is "#1"]', function (done) {
var offset = "#1";
var contract = {
'function': 'testGetPreBlockHash',
"args": "[\"" + distance + "\"]",
"args": "[\"" + offset + "\"]",
};
neb.api.call(sourceAccount.getAddressString(), contractAddress, Unit.nasToBasic(10), nonce, 200000, 1000000, contract).then(function(resp){
console.log(JSON.stringify(resp));
expect(resp.execute_err).to.be.equal("Call: getPreBlockHash: invalid distance");
expect(resp.execute_err).to.be.equal("Call: getPreBlockHash: invalid offset");
done();
}).catch(function(err) {
console.log(err);
done(err);
});
});

it ('6. test feature getPreBlockHash 4/5[distance is 0]', function (done) {
var distance = 0;
it ('6. test feature getPreBlockHash 4/5[offset is 0]', function (done) {
var offset = 0;
var contract = {
'function': 'testGetPreBlockHash',
"args": '[' + distance + ']',
"args": '[' + offset + ']',
};
neb.api.call(sourceAccount.getAddressString(), contractAddress, Unit.nasToBasic(10), nonce, 200000, 1000000, contract).then(function(resp){
console.log(JSON.stringify(resp));
expect(resp.execute_err).to.be.equal("Call: getPreBlockHash: invalid distance");
expect(resp.execute_err).to.be.equal("Call: getPreBlockHash: invalid offset");
done();
}).catch(function(err) {
console.log(err);
done(err);
});
});

it ('7. test feature getPreBlockHash 5/5[distance is too large]', function (done) {
var distance = 11111111111111;
it ('7. test feature getPreBlockHash 5/5[offset is too large]', function (done) {
var offset = 11111111111111;
var contract = {
'function': 'testGetPreBlockHash',
"args": '[' + distance + ']',
"args": '[' + offset + ']',
};
neb.api.call(sourceAccount.getAddressString(), contractAddress, Unit.nasToBasic(10), nonce, 200000, 1000000, contract).then(function(resp){
console.log(JSON.stringify(resp));
Expand All @@ -241,11 +241,11 @@ describe('test transfer from contract', function () {
});
});

it ('8. test feature getPreBlockSeed 1/5[distance is 1]', function (done) {
var distance = 1;
it ('8. test feature getPreBlockSeed 1/5[offset is 1]', function (done) {
var offset = 1;
var contract = {
'function': 'testGetPreBlockSeed',
"args": '[' + distance + ']',
"args": '[' + offset + ']',
};
var seed;
var height;
Expand All @@ -255,7 +255,7 @@ describe('test transfer from contract', function () {
seed = result.seed;
console.log(seed);
height = result.height;
return neb.api.getBlockByHeight(height - distance);
return neb.api.getBlockByHeight(height - offset);
}).then(function(resp) {
console.log(JSON.stringify(resp));
expect(resp.randomSeed).to.be.equal(seed);
Expand All @@ -266,11 +266,11 @@ describe('test transfer from contract', function () {
});
});

it ('9. test feature getPreBlockSeed 2/5[distance is "1"]', function (done) {
var distance = 1;
it ('9. test feature getPreBlockSeed 2/5[offset is "1"]', function (done) {
var offset = 1;
var contract = {
'function': 'testGetPreBlockSeed',
"args": "[\"" + distance + "\"]",
"args": "[\"" + offset + "\"]",
};
var seed;
var height;
Expand All @@ -279,7 +279,7 @@ describe('test transfer from contract', function () {
var result = JSON.parse(resp.result);
seed = result.seed;
height = result.height;
return neb.api.getBlockByHeight(height - distance);
return neb.api.getBlockByHeight(height - offset);
}).then(function(resp) {
// console.log(JSON.stringify(resp));
expect(resp.randomSeed).to.be.equal(seed);
Expand All @@ -290,27 +290,27 @@ describe('test transfer from contract', function () {
});
});

it ('10. test feature getPreBlockSeed 3/5[distance is 0]', function (done) {
var distance = 0;
it ('10. test feature getPreBlockSeed 3/5[offset is 0]', function (done) {
var offset = 0;
var contract = {
'function': 'testGetPreBlockSeed',
"args": '[' + distance + ']',
"args": '[' + offset + ']',
};
neb.api.call(sourceAccount.getAddressString(), contractAddress, Unit.nasToBasic(10), nonce, 200000, 1000000, contract).then(function(resp){
console.log(JSON.stringify(resp));
expect(resp.execute_err).to.be.equal("Call: getPreBlockSeed: invalid distance");
expect(resp.execute_err).to.be.equal("Call: getPreBlockSeed: invalid offset");
done();
}).catch(function(err) {
console.log(err);
done(err);
});
});

it ('11. test feature getPreBlockSeed 4/5[distance is too large]', function (done) {
var distance = 11111111111111;
it ('11. test feature getPreBlockSeed 4/5[offset is too large]', function (done) {
var offset = 11111111111111;
var contract = {
'function': 'testGetPreBlockSeed',
"args": '[' + distance + ']',
"args": '[' + offset + ']',
};
neb.api.call(sourceAccount.getAddressString(), contractAddress, Unit.nasToBasic(10), nonce, 200000, 1000000, contract).then(function(resp){
console.log(JSON.stringify(resp));
Expand All @@ -321,15 +321,15 @@ describe('test transfer from contract', function () {
done(err);
});
});
it ('12. test feature getPreBlockSeed 5/5[distance is "#1"]', function (done) {
var distance = "#1";
it ('12. test feature getPreBlockSeed 5/5[offset is "#1"]', function (done) {
var offset = "#1";
var contract = {
'function': 'testGetPreBlockSeed',
"args": "[\"" + distance + "\"]",
"args": "[\"" + offset + "\"]",
};
neb.api.call(sourceAccount.getAddressString(), contractAddress, Unit.nasToBasic(10), nonce, 200000, 1000000, contract).then(function(resp){
console.log(JSON.stringify(resp));
expect(resp.execute_err).to.be.equal("Call: getPreBlockSeed: invalid distance");
expect(resp.execute_err).to.be.equal("Call: getPreBlockSeed: invalid offset");
done();
}).catch(function(err) {
console.log(err);
Expand Down
2 changes: 1 addition & 1 deletion nebtestkit/cases/testnet_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var TestNet = function (env) {
} else if (env === "testneb2") {

this.ChainId = 1002;
this.sourceAccount = new Wallet.Account("25a3a441a34658e7a595a0eda222fa43ac51bd223017d17b420674fb6d0a4d52");
this.sourceAccount = new Wallet.Account("1d3fe06a53919e728315e2ccca41d4aa5b190845a79007797517e62dbc0df454");
this.coinbase = "n1SAeQRVn33bamxN4ehWUT7JGdxipwn8b17";
this.apiEndPoint = "http://34.205.26.12:8685";

Expand Down

0 comments on commit 27d5226

Please sign in to comment.