Skip to content

Commit 47f05e1

Browse files
authoredJan 16, 2023
test(bmc): Handle Relay Message when neither source nor destination is ICON chain (#777)
1 parent 6d54e2e commit 47f05e1

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
 

‎javascore/bmc/src/test/java/foundation/icon/btp/bmc/BTPMessageCenterTest.java

+33
Original file line numberDiff line numberDiff line change
@@ -697,8 +697,41 @@ public void sendFeeGathering() {
697697
.thenReturn(null);
698698
// successful sendFeeGathering
699699
score.invoke(owner, "sendFeeGathering");
700+
}
701+
702+
@Test
703+
public void handleRelayMessageMultipleChain() {
704+
String arcticLink = getDestinationBTPAddress("0x228.arctic", "0x1111111111111111111111111111111111111111");
705+
String bscLink = getDestinationBTPAddress("0x38.bsc", "0x0000000000000000000000000000000000000004");
706+
Account relay = registerRelayer();
707+
708+
addLink(arcticLink);
709+
addLink(bscLink);
710+
711+
score.invoke(owner, "addRelay", arcticLink, relay.getAddress());
712+
713+
// for confirmation in eventLog
714+
BTPAddress d = new BTPAddress("0x38.bsc", "0x0000000000000000000000000000000000000004");
715+
BTPAddress s = new BTPAddress("0x228.arctic", "0x1111111111111111111111111111111111111111");
716+
717+
BTPMessage m = new BTPMessage();
718+
m.setSrc(s);
719+
m.setDst(d);
720+
m.setSn(BigInteger.valueOf(10));
721+
m.setSvc("bts");
722+
m.setPayload("messageToBTS".getBytes());
723+
byte[] byt = m.toBytes();
724+
725+
/* This base64 message was generated from the BTP Message above */
726+
String base64 = "-N743Lja-NhVuND4zvjMuDlidHA6Ly8weDEuaWNvbi9jeDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDQBuI74jLg9YnRwOi8vMHgyMjguYXJjdGljLzB4MTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMbg5YnRwOi8vMHgzOC5ic2MvMHgwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDA0g2J0cwqMbWVzc2FnZVRvQlRThAFK_nM=";
727+
728+
score.invoke(relay, "handleRelayMessage", arcticLink, base64);
700729

730+
// though the service type is "bts", bts does not need to be registered as service on ICON
731+
// as it is intended for bts of destination BSC chain
732+
// ICON just forwards the message to BSC using Message event with required data
701733

734+
verify(scoreSpy).Message(eq(bscLink), eq(BigInteger.TWO), eq(byt));
702735
}
703736

704737
@Test

0 commit comments

Comments
 (0)