@@ -1010,32 +1010,140 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () {
1010
1010
] ) ;
1011
1011
} ) ;
1012
1012
1013
- it ( '@xts should reject eth_sendRawTransaction requests for HBAR crypto transfers to reserved system account addresses (accounts ≤ 0.0.750) with INVALID_CONTRACT_ID.' , async function ( ) {
1014
- // https://github.com/hiero-ledger/hiero-consensus-node/blob/main/hedera-node/docs/system-accounts-operations.md
1015
- const hederaSystemAccounts = [
1016
- // system accounts
1017
- '0x0000000000000000000000000000000000000002' , // 0.0.2 treasury
1018
- '0x0000000000000000000000000000000000000003' , // 0.0.3
1019
- '0x0000000000000000000000000000000000000032' , // 0.0.50 system admin
1020
- '0x0000000000000000000000000000000000000037' , // 0.0.55 address book admin
1021
- '0x0000000000000000000000000000000000000039' , // 0.0.57 exchange rates admin
1022
- '0x000000000000000000000000000000000000003a' , // 0.0.58 freeze admin
1023
- '0x000000000000000000000000000000000000003b' , // 0.0.59 system delete admin
1024
- '0x000000000000000000000000000000000000003c' , // 0.0.60 system undelete admin
1025
-
1026
- // system contracts (precompiles)
1027
- '0x0000000000000000000000000000000000000167' , // 0.0.359 HTS
1028
- '0x0000000000000000000000000000000000000168' , // 0.0.360 Exchange Rate
1029
- '0x0000000000000000000000000000000000000169' , // 0.0.361 PRNG
1030
- '0x000000000000000000000000000000000000016a' , // 0.0.362 HAS
1031
-
1032
- // non-existent accounts
1033
- '0x00000000000000000000000000000000000001C2' , // 0.0.450
1034
- '0x00000000000000000000000000000000000001FE' , // 0.0.510
1035
- '0x00000000000000000000000000000000000002EE' , // 0.0.750
1036
- ] ;
1037
-
1038
- for ( const address of hederaSystemAccounts ) {
1013
+ // https://github.com/hiero-ledger/hiero-consensus-node/blob/main/hedera-node/docs/system-accounts-operations.md
1014
+ const hederaReservedAccounts = [
1015
+ // system accounts (≤ 0.0.750) - should return INVALID_CONTRACT_ID
1016
+ {
1017
+ address : '0x0000000000000000000000000000000000000002' ,
1018
+ description : '0.0.2 treasury' ,
1019
+ expectedError : 'INVALID_CONTRACT_ID' ,
1020
+ } ,
1021
+ {
1022
+ address : '0x0000000000000000000000000000000000000003' ,
1023
+ description : '0.0.3' ,
1024
+ expectedError : 'INVALID_CONTRACT_ID' ,
1025
+ } ,
1026
+ {
1027
+ address : '0x0000000000000000000000000000000000000032' ,
1028
+ description : '0.0.50 system admin' ,
1029
+ expectedError : 'INVALID_CONTRACT_ID' ,
1030
+ } ,
1031
+ {
1032
+ address : '0x0000000000000000000000000000000000000037' ,
1033
+ description : '0.0.55 address book admin' ,
1034
+ expectedError : 'INVALID_CONTRACT_ID' ,
1035
+ } ,
1036
+ {
1037
+ address : '0x0000000000000000000000000000000000000039' ,
1038
+ description : '0.0.57 exchange rates admin' ,
1039
+ expectedError : 'INVALID_CONTRACT_ID' ,
1040
+ } ,
1041
+ {
1042
+ address : '0x000000000000000000000000000000000000003a' ,
1043
+ description : '0.0.58 freeze admin' ,
1044
+ expectedError : 'INVALID_CONTRACT_ID' ,
1045
+ } ,
1046
+ {
1047
+ address : '0x000000000000000000000000000000000000003b' ,
1048
+ description : '0.0.59 system delete admin' ,
1049
+ expectedError : 'INVALID_CONTRACT_ID' ,
1050
+ } ,
1051
+ {
1052
+ address : '0x000000000000000000000000000000000000003c' ,
1053
+ description : '0.0.60 system undelete admin' ,
1054
+ expectedError : 'INVALID_CONTRACT_ID' ,
1055
+ } ,
1056
+
1057
+ // system contracts (precompiles) (≤ 0.0.750) - should return INVALID_CONTRACT_ID
1058
+ {
1059
+ address : '0x0000000000000000000000000000000000000167' ,
1060
+ description : '0.0.359 HTS' ,
1061
+ expectedError : 'INVALID_CONTRACT_ID' ,
1062
+ } ,
1063
+ {
1064
+ address : '0x0000000000000000000000000000000000000168' ,
1065
+ description : '0.0.360 Exchange Rate' ,
1066
+ expectedError : 'INVALID_CONTRACT_ID' ,
1067
+ } ,
1068
+ {
1069
+ address : '0x0000000000000000000000000000000000000169' ,
1070
+ description : '0.0.361 PRNG' ,
1071
+ expectedError : 'INVALID_CONTRACT_ID' ,
1072
+ } ,
1073
+ {
1074
+ address : '0x000000000000000000000000000000000000016a' ,
1075
+ description : '0.0.362 HAS' ,
1076
+ expectedError : 'INVALID_CONTRACT_ID' ,
1077
+ } ,
1078
+ {
1079
+ address : '0x000000000000000000000000000000000000016b' ,
1080
+ description : '0.0.363 HSS' ,
1081
+ expectedError : 'INVALID_CONTRACT_ID' ,
1082
+ } ,
1083
+
1084
+ // non-existent accounts (≤ 0.0.750) - should return INVALID_CONTRACT_ID
1085
+ {
1086
+ address : '0x00000000000000000000000000000000000001C2' ,
1087
+ description : '0.0.450' ,
1088
+ expectedError : 'INVALID_CONTRACT_ID' ,
1089
+ } ,
1090
+ {
1091
+ address : '0x00000000000000000000000000000000000001FE' ,
1092
+ description : '0.0.510' ,
1093
+ expectedError : 'INVALID_CONTRACT_ID' ,
1094
+ } ,
1095
+ {
1096
+ address : '0x00000000000000000000000000000000000002EE' ,
1097
+ description : '0.0.750' ,
1098
+ expectedError : 'INVALID_CONTRACT_ID' ,
1099
+ } ,
1100
+
1101
+ // accounts (> 0.0.750) - non-existent should return INVALID_ALIAS_KEY
1102
+ {
1103
+ address : '0x00000000000000000000000000000000000002f1' ,
1104
+ description : '0.0.753 (non-existent)' ,
1105
+ expectedError : 'INVALID_ALIAS_KEY' ,
1106
+ } ,
1107
+ {
1108
+ address : '0x000000000000000000000000000000000000032A' ,
1109
+ description : '0.0.810 (non-existent)' ,
1110
+ expectedError : 'INVALID_ALIAS_KEY' ,
1111
+ } ,
1112
+
1113
+ // accounts (> 0.0.750) - existent should succeed (null = no error expected)
1114
+ {
1115
+ address : '0x0000000000000000000000000000000000000320' ,
1116
+ description : '0.0.800 staking reward account' ,
1117
+ expectedError : null ,
1118
+ } ,
1119
+ {
1120
+ address : '0x0000000000000000000000000000000000000321' ,
1121
+ description : '0.0.801 node reward account' ,
1122
+ expectedError : null ,
1123
+ } ,
1124
+ {
1125
+ address : '0x00000000000000000000000000000000000003A2' ,
1126
+ description : '0.0.930 (existent)' ,
1127
+ expectedError : null ,
1128
+ } ,
1129
+ {
1130
+ address : '0x00000000000000000000000000000000000003C0' ,
1131
+ description : '0.0.960 (existent)' ,
1132
+ expectedError : null ,
1133
+ } ,
1134
+ {
1135
+ address : '0x00000000000000000000000000000000000003E7' ,
1136
+ description : '0.0.999 (existent)' ,
1137
+ expectedError : null ,
1138
+ } ,
1139
+ ] ;
1140
+
1141
+ hederaReservedAccounts . forEach ( ( { address, description, expectedError } ) => {
1142
+ const testDescription = expectedError
1143
+ ? `@xts should reject HBAR transfer to ${ description } (${ address } ) with ${ expectedError } `
1144
+ : `@xts should successfully execute HBAR transfer to ${ description } (${ address } )` ;
1145
+
1146
+ it ( testDescription , async function ( ) {
1039
1147
const sendHbarTx = {
1040
1148
...defaultLegacyTransactionData ,
1041
1149
value : ONE_TINYBAR ,
@@ -1048,58 +1156,14 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () {
1048
1156
const txHash = await relay . sendRawTransaction ( signedSendHbarTx ) ;
1049
1157
const txReceipt = await relay . pollForValidTransactionReceipt ( txHash ) ;
1050
1158
1051
- expect ( txReceipt . revertReason ) . to . not . be . null ;
1052
- expect ( txReceipt . revertReason ) . to . not . be . empty ;
1053
- expect ( Buffer . from ( ( txReceipt . revertReason as string ) . slice ( 2 ) , 'hex' ) . toString ( 'utf8' ) ) . to . equal (
1054
- 'INVALID_CONTRACT_ID' ,
1055
- ) ;
1056
- }
1057
- } ) ;
1058
-
1059
- it ( '@xts should validate HBAR transfers to reserved system accounts based on account existence for accounts from 0.0.750 to 0.0.999' , async function ( ) {
1060
- const hederaSystemAccounts = [
1061
- // non-existent accounts
1062
- '0x00000000000000000000000000000000000002f1' , // 0.0.753
1063
- '0x000000000000000000000000000000000000032A' , // 0.0.810
1064
-
1065
- // system accounts
1066
- '0x0000000000000000000000000000000000000320' , // 0.0.800 staking reward account;
1067
- '0x0000000000000000000000000000000000000321' , // 0.0.801 node reward account
1068
-
1069
- // existent accounts
1070
- '0x00000000000000000000000000000000000003A2' , // 0.0.930
1071
- '0x00000000000000000000000000000000000003A2' , // 0.0.960
1072
- '0x00000000000000000000000000000000000003A2' , // 0.0.999
1073
- ] ;
1074
-
1075
- for ( const address of hederaSystemAccounts ) {
1076
- const sendHbarTx = {
1077
- ...defaultLegacyTransactionData ,
1078
- value : ONE_TINYBAR ,
1079
- to : address ,
1080
- nonce : await relay . getAccountNonce ( accounts [ 1 ] . address ) ,
1081
- gasPrice : await relay . gasPrice ( ) ,
1082
- } ;
1083
-
1084
- const signedSendHbarTx = await accounts [ 1 ] . wallet . signTransaction ( sendHbarTx ) ;
1085
- const txHash = await relay . sendRawTransaction ( signedSendHbarTx ) ;
1086
- const txReceipt = await relay . pollForValidTransactionReceipt ( txHash ) ;
1087
-
1088
- // Crypto Transfers are successful if accounts exist
1089
- try {
1090
- const accountInfo = await global . mirrorNode . get ( `/accounts/${ address } ` ) ;
1091
- expect ( accountInfo ) . to . exist ;
1159
+ if ( expectedError ) {
1160
+ expect ( txReceipt . revertReason ) . to . not . be . empty ;
1161
+ expect ( Buffer . from ( txReceipt . revertReason ! . slice ( 2 ) , 'hex' ) . toString ( 'utf8' ) ) . to . equal ( expectedError ) ;
1162
+ } else {
1092
1163
expect ( txReceipt . status ) . to . equal ( '0x1' ) ;
1093
1164
expect ( txReceipt . revertReason ) . to . be . undefined ;
1094
- } catch ( error ) {
1095
- expect ( error . status ) . to . equal ( 404 ) ;
1096
- expect ( txReceipt . revertReason ) . to . not . be . null ;
1097
- expect ( txReceipt . revertReason ) . to . not . be . empty ;
1098
- expect ( Buffer . from ( ( txReceipt . revertReason as string ) . slice ( 2 ) , 'hex' ) . toString ( 'utf8' ) ) . to . equal (
1099
- 'INVALID_ALIAS_KEY' ,
1100
- ) ;
1101
1165
}
1102
- }
1166
+ } ) ;
1103
1167
} ) ;
1104
1168
1105
1169
it ( '@xts should execute "eth_sendRawTransaction" for deterministic deployment transaction' , async function ( ) {
0 commit comments