@@ -920,6 +920,115 @@ describe('@api RPC Server Acceptance Tests', function () {
920920 expect ( res ) . to . not . be . equal ( '0x' ) ;
921921 expect ( res ) . to . not . be . equal ( '0x0' ) ;
922922 } ) ;
923+
924+ it ( 'should execute "eth_estimateGas" with to, from, value and gas filed' , async function ( ) {
925+ const res = await relay . call ( 'eth_estimateGas' , [ {
926+ from : '0x114f60009ee6b84861c0cdae8829751e517bc4d7' ,
927+ to : '0xae410f34f7487e2cd03396499cebb09b79f45d6e' ,
928+ value : '0xa688906bd8b00000' ,
929+ gas : '0xd97010'
930+ } ] , requestId ) ;
931+ expect ( res ) . to . contain ( '0x' ) ;
932+ expect ( res ) . to . not . be . equal ( '0x' ) ;
933+ expect ( res ) . to . not . be . equal ( '0x0' ) ;
934+ } ) ;
935+
936+ it ( 'should execute "eth_estimateGas" with to, from, value,accessList gas filed' , async function ( ) {
937+ const res = await relay . call ( 'eth_estimateGas' , [ {
938+ from : '0x114f60009ee6b84861c0cdae8829751e517bc4d7' ,
939+ to : '0xae410f34f7487e2cd03396499cebb09b79f45d6e' ,
940+ value : '0xa688906bd8b00000' ,
941+ gas : '0xd97010' ,
942+ accessList : [ ]
943+ } ] , requestId ) ;
944+ expect ( res ) . to . contain ( '0x' ) ;
945+ expect ( res ) . to . not . be . equal ( '0x' ) ;
946+ expect ( res ) . to . not . be . equal ( '0x0' ) ;
947+ } ) ;
948+
949+ it ( 'should not be able to execute "eth_estimateGas" with no transaction object' , async function ( ) {
950+ try {
951+ await relay . call ( 'eth_estimateGas' , [ ] , requestId ) ;
952+ Assertions . expectedError ( ) ;
953+ } catch ( error ) {
954+ const err = JSON . parse ( error . body ) ;
955+ expect ( error ) . to . not . be . null ;
956+ expect ( err . error . name ) . to . be . equal ( 'Missing required parameters' ) ;
957+ expect ( err . error . message . endsWith ( 'Missing value for required parameter 0' ) ) . to . be . true ;
958+ }
959+ } ) ;
960+
961+ it ( 'should not be able to execute "eth_estimateGas" with wrong from field' , async function ( ) {
962+ try {
963+ await relay . call ( 'eth_estimateGas' , [ {
964+ from : '0x114f60009ee6b84861c0cdae8829751e517bc4d7' ,
965+ to : '0xae410f34f7487e2cd03396499cebb09b79f45' ,
966+ value : '0xa688906bd8b00000' ,
967+ gas : '0xd97010' ,
968+ accessList : [ ]
969+ } ] , requestId ) ;
970+ Assertions . expectedError ( ) ;
971+ } catch ( error ) {
972+ const err = JSON . parse ( error . body ) ;
973+ expect ( error ) . to . not . be . null ;
974+ expect ( err . error . name ) . to . be . equal ( 'Invalid parameter' ) ;
975+ expect ( err . error . message . endsWith ( `Invalid parameter 'to' for TransactionObject: Expected 0x prefixed string representing the address (20 bytes)` ) ) . to . be . true ;
976+ }
977+ } ) ;
978+
979+ it ( 'should not be able to execute "eth_estimateGas" with wrong to field' , async function ( ) {
980+ try {
981+ await relay . call ( 'eth_estimateGas' , [ {
982+ from : '0x114f60009ee6b84861c0cdae8829751e517bc4d7' ,
983+ to : '0xae410f34f7487e2cd03396499cebb09b79f45' ,
984+ value : '0xa688906bd8b00000' ,
985+ gas : '0xd97010' ,
986+ accessList : [ ]
987+ } ] , requestId ) ;
988+ Assertions . expectedError ( ) ;
989+ } catch ( error ) {
990+ const err = JSON . parse ( error . body ) ;
991+ expect ( error ) . to . not . be . null ;
992+ expect ( err . error . name ) . to . be . equal ( 'Invalid parameter' ) ;
993+ expect ( err . error . message . endsWith ( `Invalid parameter 'to' for TransactionObject: Expected 0x prefixed string representing the address (20 bytes)` ) ) . to . be . true ;
994+ }
995+ } ) ;
996+
997+ it ( 'should not be able to execute "eth_estimateGas" with wrong value field' , async function ( ) {
998+ try {
999+ await relay . call ( 'eth_estimateGas' , [ {
1000+ from : '0x114f60009ee6b84861c0cdae8829751e517bc4d7' ,
1001+ to : '0xae410f34f7487e2cd03396499cebb09b79f45d6e' ,
1002+ value : '123' ,
1003+ gas : '0xd97010' ,
1004+ accessList : [ ]
1005+ } ] , requestId ) ;
1006+ Assertions . expectedError ( ) ;
1007+ } catch ( error ) {
1008+ const err = JSON . parse ( error . body ) ;
1009+ expect ( error ) . to . not . be . null ;
1010+ expect ( err . error . name ) . to . be . equal ( 'Invalid parameter' ) ;
1011+ expect ( err . error . message . endsWith ( `Invalid parameter 'value' for TransactionObject: Expected 0x prefixed hexadecimal value` ) ) . to . be . true ;
1012+ }
1013+ } ) ;
1014+
1015+ it ( 'should not be able to execute "eth_estimateGas" with wrong gas field' , async function ( ) {
1016+ try {
1017+ await relay . call ( 'eth_estimateGas' , [ {
1018+ from : '0x114f60009ee6b84861c0cdae8829751e517bc4d7' ,
1019+ to : '0xae410f34f7487e2cd03396499cebb09b79f45d6e' ,
1020+ value : '0xa688906bd8b00000' ,
1021+ gas : '123' ,
1022+ accessList : [ ]
1023+ } ] , requestId ) ;
1024+ Assertions . expectedError ( ) ;
1025+ } catch ( error ) {
1026+ const err = JSON . parse ( error . body ) ;
1027+ expect ( error ) . to . not . be . null ;
1028+ expect ( err . error . name ) . to . be . equal ( 'Invalid parameter' ) ;
1029+ expect ( err . error . message . endsWith ( `Invalid parameter 'gas' for TransactionObject: Expected 0x prefixed hexadecimal value` ) ) . to . be . true ;
1030+ }
1031+ } ) ;
9231032 } ) ;
9241033
9251034 describe ( 'eth_gasPrice' , async function ( ) {
0 commit comments