@@ -3798,6 +3798,77 @@ describe('Blockchain Node', () => {
37983798 } ) ;
37993799 } )
38003800
3801+ it ( 'accepts a transfer transaction lacking gas fee' , ( ) => {
3802+ // NOTE: transfer all amount of the balance
3803+ const fromBalance = parseOrLog ( syncRequest ( 'GET' ,
3804+ server1 + `/get_value?ref=/accounts/${ account09 . address } /balance` ) . body . toString ( 'utf-8' ) ) . result ;
3805+ const client = jayson . client . http ( server1 + '/json-rpc' ) ;
3806+ const txBody = {
3807+ operation : {
3808+ type : 'SET_VALUE' ,
3809+ ref : `/transfer/${ account09 . address } /${ account3 . address } /${ Date . now ( ) } /value` ,
3810+ value : fromBalance , // all amount of the balance
3811+ } ,
3812+ gas_price : 500 , // non-zero gas price
3813+ timestamp : Date . now ( ) ,
3814+ nonce : - 1 , // unordered nonce
3815+ } ;
3816+ const signature =
3817+ ainUtil . ecSignTransaction ( txBody , Buffer . from ( account09 . private_key , 'hex' ) ) ;
3818+ return client . request ( JSON_RPC_METHODS . AIN_SEND_SIGNED_TRANSACTION_DRYRUN , {
3819+ tx_body : txBody ,
3820+ signature,
3821+ protoVer : BlockchainConsts . CURRENT_PROTOCOL_VERSION
3822+ } )
3823+ . then ( ( res ) => {
3824+ const result = _ . get ( res , 'result.result' , null ) ;
3825+ expect ( result ) . to . not . equal ( null ) ;
3826+ assert . deepEqual ( res . result , {
3827+ protoVer : BlockchainConsts . CURRENT_PROTOCOL_VERSION ,
3828+ result : {
3829+ result : {
3830+ "bandwidth_gas_amount" : 1 ,
3831+ "code" : 0 ,
3832+ "func_results" : {
3833+ "_transfer" : {
3834+ "bandwidth_gas_amount" : 2000 ,
3835+ "code" : 0 ,
3836+ "op_results" : {
3837+ "0" : {
3838+ "path" : "/accounts/0x09A0d53FDf1c36A131938eb379b98910e55EEfe1/balance" ,
3839+ "result" : {
3840+ "bandwidth_gas_amount" : 1 ,
3841+ "code" : 0
3842+ }
3843+ } ,
3844+ "1" : {
3845+ "path" : "/accounts/0x758fd59D3f8157Ae4458f8E29E2A8317be3d5974/balance" ,
3846+ "result" : {
3847+ "bandwidth_gas_amount" : 1 ,
3848+ "code" : 0
3849+ }
3850+ }
3851+ }
3852+ }
3853+ } ,
3854+ "gas_amount_charged" : 3281 ,
3855+ "gas_amount_total" : {
3856+ "bandwidth" : {
3857+ "service" : 2003
3858+ } ,
3859+ "state" : {
3860+ "service" : 1278
3861+ }
3862+ } ,
3863+ "gas_cost_total" : 1.6405 ,
3864+ "is_dryrun" : true
3865+ } ,
3866+ tx_hash : CommonUtil . hashSignature ( signature ) ,
3867+ }
3868+ } ) ;
3869+ } ) ;
3870+ } )
3871+
38013872 it ( 'rejects a transaction with an invalid signature.' , ( ) => {
38023873 const client = jayson . client . http ( server1 + '/json-rpc' ) ;
38033874 const txBody = {
@@ -4597,6 +4668,77 @@ describe('Blockchain Node', () => {
45974668 } ) ;
45984669 } )
45994670
4671+ it ( 'accepts a transfer transaction lacking gas fee' , ( ) => {
4672+ // NOTE: transfer all amount of the balance
4673+ const fromBalance = parseOrLog ( syncRequest ( 'GET' ,
4674+ server1 + `/get_value?ref=/accounts/${ account09 . address } /balance` ) . body . toString ( 'utf-8' ) ) . result ;
4675+ const client = jayson . client . http ( server1 + '/json-rpc' ) ;
4676+ const txBody = {
4677+ operation : {
4678+ type : 'SET_VALUE' ,
4679+ ref : `/transfer/${ account09 . address } /${ account3 . address } /${ Date . now ( ) } /value` ,
4680+ value : fromBalance , // all amount of the balance
4681+ } ,
4682+ gas_price : 500 , // non-zero gas price
4683+ timestamp : Date . now ( ) ,
4684+ nonce : - 1 , // unordered nonce
4685+ } ;
4686+ const signature =
4687+ ainUtil . ecSignTransaction ( txBody , Buffer . from ( account09 . private_key , 'hex' ) ) ;
4688+ return client . request ( JSON_RPC_METHODS . AIN_SEND_SIGNED_TRANSACTION , {
4689+ tx_body : txBody ,
4690+ signature,
4691+ protoVer : BlockchainConsts . CURRENT_PROTOCOL_VERSION
4692+ } )
4693+ . then ( ( res ) => {
4694+ const result = _ . get ( res , 'result.result' , null ) ;
4695+ expect ( result ) . to . not . equal ( null ) ;
4696+ assert . deepEqual ( res . result , {
4697+ protoVer : BlockchainConsts . CURRENT_PROTOCOL_VERSION ,
4698+ result : {
4699+ result : {
4700+ "bandwidth_gas_amount" : 1 ,
4701+ "code" : 11001 ,
4702+ "func_results" : {
4703+ "_transfer" : {
4704+ "bandwidth_gas_amount" : 0 ,
4705+ "code" : 0 ,
4706+ "op_results" : {
4707+ "0" : {
4708+ "path" : "/accounts/0x09A0d53FDf1c36A131938eb379b98910e55EEfe1/balance" ,
4709+ "result" : {
4710+ "bandwidth_gas_amount" : 1 ,
4711+ "code" : 0
4712+ }
4713+ } ,
4714+ "1" : {
4715+ "path" : "/accounts/0x758fd59D3f8157Ae4458f8E29E2A8317be3d5974/balance" ,
4716+ "result" : {
4717+ "bandwidth_gas_amount" : 1 ,
4718+ "code" : 0
4719+ }
4720+ }
4721+ }
4722+ }
4723+ } ,
4724+ "gas_amount_charged" : 3 ,
4725+ "gas_amount_total" : {
4726+ "bandwidth" : {
4727+ "service" : 3
4728+ } ,
4729+ "state" : {
4730+ "service" : 364
4731+ }
4732+ } ,
4733+ "gas_cost_total" : 0.0015 ,
4734+ "message" : "Failed to collect gas fee: balance too low (0 / 0.1835)"
4735+ } ,
4736+ tx_hash : CommonUtil . hashSignature ( signature ) ,
4737+ }
4738+ } ) ;
4739+ } ) ;
4740+ } )
4741+
46004742 it ( 'accepts a multi-set transaction with account registration gas amount from nonce' , ( ) => {
46014743 // NOTE: account4 does not have balance nor nonce/timestamp.
46024744 const client = jayson . client . http ( server1 + '/json-rpc' ) ;
0 commit comments