@@ -11,18 +11,35 @@ import {
1111 ServiceEndpoint ,
1212} from "../../../src/exports.js" ;
1313import { Client } from "../../../src/index.js" ;
14-
15- describe ( "Node Update Integration Network Tests" , function ( ) {
14+ import {
15+ mirrorNetwork ,
16+ node2Address ,
17+ node2PortToReplace ,
18+ network ,
19+ } from "./NodeConstants.js" ;
20+
21+ const restoreOriginalGrpcWebProxyEndpoint = async ( client ) => {
22+ const response = await new NodeUpdateTransaction ( )
23+ . setNodeId ( 1 )
24+ . setNodeAccountIds ( [ AccountId . fromString ( "0.0.3" ) ] )
25+ . setGrpcWebProxyEndpoint (
26+ new ServiceEndpoint ( )
27+ . setDomainName ( "envoy-proxy-node2-svc.solo.svc.cluster.local" )
28+ . setPort ( 8080 ) ,
29+ )
30+ . execute ( client ) ;
31+ const receipt = await response . getReceipt ( client ) ;
32+ expect ( receipt . status ) . to . equal ( Status . Success ) ;
33+ } ;
34+
35+ describe ( "Node Update Integration Tests" , function ( ) {
1636 let client ;
1737 let operatorAccountId ;
1838 let operatorKey ;
1939
2040 beforeEach ( function ( ) {
2141 // Initialize client with integration network
22- client = Client . forNetwork ( {
23- "127.0.0.1:50211" : "0.0.3" ,
24- "127.0.0.1:51211" : "0.0.4" ,
25- } ) . setMirrorNetwork ( [ "localhost:5600" ] ) ;
42+ client = Client . forNetwork ( network ) . setMirrorNetwork ( mirrorNetwork ) ;
2643
2744 // Set the operator to be account 0.0.2
2845 operatorAccountId = AccountId . fromString ( "0.0.2" ) ;
@@ -41,8 +58,8 @@ describe("Node Update Integration Network Tests", function () {
4158
4259 it ( "should execute node update transaction" , async function ( ) {
4360 const response = await new NodeUpdateTransaction ( )
44- . setNodeId ( 0 )
45- . setNodeAccountIds ( [ AccountId . fromString ( "0.0.4 " ) ] )
61+ . setNodeId ( 1 )
62+ . setNodeAccountIds ( [ AccountId . fromString ( "0.0.3 " ) ] )
4663 . setDescription ( "testUpdated" )
4764 . setDeclineReward ( true )
4865 . setGrpcWebProxyEndpoint (
@@ -58,18 +75,23 @@ describe("Node Update Integration Network Tests", function () {
5875
5976 it ( "should delete grpc web proxy endpoint" , async function ( ) {
6077 const response = await new NodeUpdateTransaction ( )
61- . setNodeId ( 0 )
78+ . setNodeId ( 1 )
79+ . setNodeAccountIds ( [ AccountId . fromString ( "0.0.3" ) ] )
6280 . deleteGrpcWebProxyEndpoint ( )
6381 . execute ( client ) ;
6482
6583 const receipt = await response . getReceipt ( client ) ;
6684 expect ( receipt . status ) . to . equal ( Status . Success ) ;
85+
86+ // Restore the original grpc web proxy endpoint
87+ await restoreOriginalGrpcWebProxyEndpoint ( client ) ;
6788 } ) ;
6889
6990 it ( "should change node account ID and revert back" , async function ( ) {
7091 // Change node account ID from 0.0.3 to 0.0.2
7192 const response1 = await new NodeUpdateTransaction ( )
7293 . setNodeId ( 0 )
94+ . setNodeAccountIds ( [ AccountId . fromString ( "0.0.4" ) ] )
7395 . setAccountId ( AccountId . fromString ( "0.0.2" ) )
7496 . execute ( client ) ;
7597
@@ -79,6 +101,7 @@ describe("Node Update Integration Network Tests", function () {
79101 // Revert the ID back to 0.0.3
80102 const response2 = await new NodeUpdateTransaction ( )
81103 . setNodeId ( 0 )
104+ . setNodeAccountIds ( [ AccountId . fromString ( "0.0.4" ) ] )
82105 . setAccountId ( AccountId . fromString ( "0.0.3" ) )
83106 . execute ( client ) ;
84107
@@ -115,10 +138,11 @@ describe("Node Update Integration Network Tests", function () {
115138 } ) ;
116139
117140 it ( "should change node account ID to the same account" , async function ( ) {
141+ console . log ( client . network ) ;
118142 const response = await new NodeUpdateTransaction ( )
119- . setNodeId ( 0 )
120- . setNodeAccountIds ( [ AccountId . fromString ( "0.0.4 " ) ] )
121- . setAccountId ( AccountId . fromString ( "0.0.3 " ) )
143+ . setNodeId ( 1 )
144+ . setNodeAccountIds ( [ AccountId . fromString ( "0.0.3 " ) ] )
145+ . setAccountId ( AccountId . fromString ( "0.0.4 " ) )
122146 . execute ( client ) ;
123147
124148 const receipt = await response . getReceipt ( client ) ;
@@ -271,7 +295,7 @@ describe("Node Update Integration Network Tests", function () {
271295 AccountId . fromString ( "0.0.3" ) ,
272296 ] )
273297 . execute ( client ) ;
274-
298+ console . log ( "tuka se ebava v maikata" ) ;
275299 const testReceipt = await testResp . getReceipt ( client ) ;
276300 expect ( testReceipt . status ) . to . equal ( Status . Success ) ;
277301 // Verify address book has been updated
@@ -288,21 +312,19 @@ describe("Node Update Integration Network Tests", function () {
288312 ) ?. [ 0 ] ;
289313
290314 // Assert the address matches the expected value
291- expect ( newNodeAddress ) . to . equal (
292- "network-node2-svc.solo.svc.cluster.local:50211" ,
293- ) ;
315+ expect ( newNodeAddress ) . to . equal ( node2Address ) ;
294316
295317 // This is not an ideal workaround - reconstruct the network state
296318 // because the mirror node returns a different address than expected
297- if (
298- newNodeAddress === "network-node2-svc.solo.svc.cluster.local:50211"
299- ) {
319+ if ( newNodeAddress === node2Address ) {
300320 const oldNetworkState = { ...network } ;
301321 delete oldNetworkState [ newNodeAddress ] ;
302322 const newNetworkState = {
303323 ...oldNetworkState ,
304- "network-node2-svc.solo.svc.cluster.local:51211" :
305- newNodeAccountID ,
324+ [ node2Address . replace (
325+ node2Address . split ( ":" ) [ 1 ] ,
326+ node2PortToReplace ,
327+ ) ] : newNodeAccountID ,
306328 } ;
307329 client . setNetwork ( newNetworkState ) ;
308330 }
@@ -328,10 +350,7 @@ describe("Node Update Integration Network Tests", function () {
328350
329351 it ( "should handle node account ID change without mirror node setup" , async function ( ) {
330352 // Create a client without mirror network
331- const networkClient = Client . forNetwork ( {
332- "127.0.0.1:50211" : "0.0.3" ,
333- "127.0.0.1:51211" : "0.0.4" ,
334- } ) ;
353+ const networkClient = Client . forNetwork ( network ) ;
335354
336355 networkClient . setOperator ( operatorAccountId , operatorKey ) ;
337356
0 commit comments