From effcb100385061c8238a064646b3db19f41ffd4c Mon Sep 17 00:00:00 2001 From: MickeyWang <1244134672@qq.com> Date: Thu, 19 Jul 2018 10:47:33 +0800 Subject: [PATCH] update gasPrice to replace 0 for transaction --- test/attest.test.ts | 2 +- test/claim.test.ts | 2 +- test/deployCodeTx.test.ts | 2 +- test/message.test.ts | 2 +- test/nep5.test.ts | 6 +++--- test/restClient.test.ts | 2 +- test/rpcClient.test.ts | 2 +- test/transfer.test.ts | 8 ++++---- test/tx.node.ts | 8 +++++++- 9 files changed, 20 insertions(+), 14 deletions(-) diff --git a/test/attest.test.ts b/test/attest.test.ts index 0b186b26..ff249acc 100644 --- a/test/attest.test.ts +++ b/test/attest.test.ts @@ -33,7 +33,7 @@ describe('test attest claim', () => { const identity = Identity.create(privateKey, '123456', ''); const ontId = identity.ontid; const address = account.address; - const gasPrice = '0'; + const gasPrice = '500'; const gasLimit = '30000'; function randomClaim(): Claim { diff --git a/test/claim.test.ts b/test/claim.test.ts index fd0873a0..9b0475fe 100644 --- a/test/claim.test.ts +++ b/test/claim.test.ts @@ -42,7 +42,7 @@ describe('test claim', () => { * Registers new ONT ID to create transaction with Events and new block */ beforeAll(async () => { - const tx = buildRegisterOntidTx(ontid, publicKey, '0', '30000'); + const tx = buildRegisterOntidTx(ontid, publicKey, '500', '30000'); tx.payer = account.address; signTransaction(tx, privateKey); diff --git a/test/deployCodeTx.test.ts b/test/deployCodeTx.test.ts index f8c68ec2..fd9b6d97 100644 --- a/test/deployCodeTx.test.ts +++ b/test/deployCodeTx.test.ts @@ -56,7 +56,7 @@ describe('test deploy contract', () => { test('test deploy with avm code', async () => { const tx = makeDeployCodeTransaction(attestClaimAvmCode, - 'name', '1.0', 'alice', 'testmail', 'desc', true, '0', '30000000'); + 'name', '1.0', 'alice', 'testmail', 'desc', true, '500', '30000000'); tx.payer = account.address; signTransaction(tx, privateKey); const result = await restClient.sendRawTransaction(tx.serialize()); diff --git a/test/message.test.ts b/test/message.test.ts index b59fa438..b3304100 100644 --- a/test/message.test.ts +++ b/test/message.test.ts @@ -53,7 +53,7 @@ describe('test message', () => { } beforeAll(async () => { - const tx = buildRegisterOntidTx(ontid, publicKey, '0', '30000'); + const tx = buildRegisterOntidTx(ontid, publicKey, '500', '30000'); tx.payer = account.address; signTransaction(tx, privateKey); diff --git a/test/nep5.test.ts b/test/nep5.test.ts index 060b24e6..eeda5666 100644 --- a/test/nep5.test.ts +++ b/test/nep5.test.ts @@ -21,7 +21,7 @@ import { PrivateKey } from '../src/crypto/PrivateKey'; import { RestClient, WebsocketClient } from '../src/index'; import Nep5TxBuilder from '../src/smartcontract/neovm/nep5TxBuilder'; import { signTransaction } from '../src/transaction/transactionBuilder'; -import { reverseHex, hexstr2str } from '../src/utils'; +import { hexstr2str, reverseHex } from '../src/utils'; import { Address } from './../src/crypto/address'; describe('test nep5', () => { @@ -39,14 +39,14 @@ describe('test nep5', () => { const codeHash = 'cacbaf1024af9eb19f981c084548df14510d85ae'; const contractAddr = new Address(reverseHex(codeHash)); - const gasPrice = '0'; + const gasPrice = '500'; const gasLimit = '30000'; const restClient = new RestClient('http://127.0.0.1:20334'); const socketClient = new WebsocketClient('http://127.0.0.1:20335'); test('test_init', async () => { - const tx = Nep5TxBuilder.init(contractAddr, '0', gasLimit, account1.address); + const tx = Nep5TxBuilder.init(contractAddr, gasPrice, gasLimit, account1.address); signTransaction(tx, private1); const response = await socketClient.sendRawTransaction(tx.serialize(), false, true); // tslint:disable:no-console diff --git a/test/restClient.test.ts b/test/restClient.test.ts index 5e5ba4db..cc3cb30e 100644 --- a/test/restClient.test.ts +++ b/test/restClient.test.ts @@ -28,7 +28,7 @@ describe('test restClient', () => { * Registers new ONT ID to create transaction with Events and new block */ beforeAll(async () => { - const tx = buildRegisterOntidTx(ontid, publicKey, '0', '30000'); + const tx = buildRegisterOntidTx(ontid, publicKey, '500', '30000'); tx.payer = account.address; signTransaction(tx, privateKey); diff --git a/test/rpcClient.test.ts b/test/rpcClient.test.ts index 9587e599..030f5ae4 100644 --- a/test/rpcClient.test.ts +++ b/test/rpcClient.test.ts @@ -28,7 +28,7 @@ describe('test rpc client', () => { * Registers new ONT ID to create transaction with Events and new block */ beforeAll(async () => { - const tx = buildRegisterOntidTx(ontid, publicKey, '0', '30000'); + const tx = buildRegisterOntidTx(ontid, publicKey, '500', '30000'); tx.payer = account.address; signTransaction(tx, privateKey); diff --git a/test/transfer.test.ts b/test/transfer.test.ts index 89404ccc..539c55de 100644 --- a/test/transfer.test.ts +++ b/test/transfer.test.ts @@ -42,8 +42,8 @@ import { signTransaction, signTx } from './../src/transaction/transactionBuilder describe('test transfer asset', () => { const socketClient = new WebsocketClient('ws://polaris1.ont.io:20335'); const restClient = new RestClient('http://polaris1.ont.io:20334'); - const gasLimit = '300000'; - const gasPrice = '0'; + const gasLimit = '20000'; + const gasPrice = '500'; const adminPrivateKey = new PrivateKey('7c47df9664e7db85c1308c080f398400cb24283f5d922e76b478b5429e821b97'); const adminAddress = new Address('AdLUBSSHUuFaak9j169hiamXUmPuCTnaRz'); @@ -62,8 +62,8 @@ describe('test transfer asset', () => { }; test('test transfer asset', async () => { const from = adminAddress; - const to = new Address('ARswehu2w1jMZU5qhckTdoZV9jogUzXfZX'); - const tx = makeTransferTx('ONG', from, to, 2*1e9, gasPrice, gasLimit); + const to = new Address('AH9B261xeBXdKH4jPyafcHcLkS2EKETbUj'); + const tx = makeTransferTx('ONG', from, to, 0.1 * 1e9, gasPrice, gasLimit); signTransaction(tx, adminPrivateKey); const response = await socketClient.sendRawTransaction(tx.serialize(), false, true); // tslint:disable:no-console diff --git a/test/tx.node.ts b/test/tx.node.ts index 71c1b9c8..f8f8c04b 100644 --- a/test/tx.node.ts +++ b/test/tx.node.ts @@ -48,7 +48,7 @@ import { signTransaction, signTx } from './../src/transaction/transactionBuilder describe('test ONT ID contract', () => { - const gasPrice = '0'; + const gasPrice = '500'; const gasLimit = '30000'; const socketClient = new WebsocketClient('ws://polaris1.ont.io:20335'); @@ -85,23 +85,29 @@ describe('test ONT ID contract', () => { const account2 = Account.create(pri2, '123456', ''); const pub2 = pri2.getPublicKey(); const ontid2 = 'did:ont:ALnvzTMkbanffAKzQwxJ3EGoBqYuR6WqcG'; + console.log('address2: ' + account2.address.toBase58()); const pri3 = new PrivateKey('7c47df9664e7db85c1308c080f398400cb24283f5d922e76b478b5429e821b97'); const account3 = Account.create(pri3, '123456', ''); const pub3 = pri3.getPublicKey(); const ontid3 = Address.generateOntid(pub3); console.log('pk3:' + pri3.getPublicKey().serializeHex()); + console.log('address3: ' + account3.address.toBase58()); + const pri4 = new PrivateKey('7c47df9664e7db85c1308c080f398400cb24283f5d922e76b478b5429e821b98'); const account4 = Account.create(pri4, '123456', ''); const pub4 = pri4.getPublicKey(); const ontid4 = Address.generateOntid(pub4); console.log('pk4:' + pri4.getPublicKey().serializeHex()); + console.log('address4: ' + account4.address.toBase58()); + const pri5 = new PrivateKey('7c47df9664e7db85c1308c080f398400cb24283f5d922e76b478b5429e821b99'); const account5 = Account.create(pri5, '123456', ''); const pub5 = pri5.getPublicKey(); const ontid5 = Address.generateOntid(pub5); + console.log('address5: ' + account5.address.toBase58()); test('testRegisterOntid', async () => {