diff --git a/test-lib/src/main/java/foundation/icon/btp/mock/ChainScore.java b/test-lib/src/main/java/foundation/icon/btp/mock/ChainScore.java index 4d0778d6..279cc82d 100644 --- a/test-lib/src/main/java/foundation/icon/btp/mock/ChainScore.java +++ b/test-lib/src/main/java/foundation/icon/btp/mock/ChainScore.java @@ -68,6 +68,12 @@ public interface ChainScore { @External(readonly=true) byte[] getBTPPublicKey(Address address, String name); + @External + void setPRepNodePublicKey(byte[] pubKey); + + @External(readonly=true) + byte[] getPRepNodePublicKey(Address address); + @External(readonly=true) long getBTPNetworkTypeID(String name); diff --git a/test-lib/src/main/java/foundation/icon/btp/test/MockGovIntegrationTest.java b/test-lib/src/main/java/foundation/icon/btp/test/MockGovIntegrationTest.java index c07629a0..5f9b1b31 100644 --- a/test-lib/src/main/java/foundation/icon/btp/test/MockGovIntegrationTest.java +++ b/test-lib/src/main/java/foundation/icon/btp/test/MockGovIntegrationTest.java @@ -26,7 +26,7 @@ import foundation.icon.score.util.StringUtil; import org.junit.jupiter.api.Tag; -import java.util.List; +import java.util.Map; import java.util.concurrent.atomic.AtomicLong; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -43,8 +43,12 @@ public interface MockGovIntegrationTest { ChainScore chainScore = chainScoreClient; static long openBTPNetwork(String networkTypeName, String name, score.Address owner) { - ensureRevision(); - ensureBTPPublicKey(); + @SuppressWarnings("unchecked") + Map netInfo = mockGovClient.request(Map.class, "icx_getNetworkInfo", null); + final String platform = (String) netInfo.getOrDefault("platform", "basic"); + + ensureRevision(platform); + ensureBTPPublicKey(platform); AtomicLong networkId = new AtomicLong(); mockGovClient.openBTPNetwork(chainScoreClient.BTPNetworkOpened((l) -> { @@ -64,24 +68,46 @@ static void closeBTPNetwork(long networkId) { networkId); } - static void ensureRevision() { - final int revision = 9; + static void ensureRevision(String platform) { + final int revision; + switch (platform) { + case "icon": + revision = 21; + break; + case "basic": + default: + revision = 9; + } if (revision != chainScore.getRevision()) { mockGov.setRevision(revision); } } - static void ensureBTPPublicKey() { + static void ensureBTPPublicKey(String platform) { String DSA = "ecdsa/secp256k1"; Address address = validatorWallet.getAddress(); - byte[] pubKey = chainScore.getBTPPublicKey(address, DSA); + byte[] pubKey; + switch (platform) { + case "icon": + pubKey = chainScore.getPRepNodePublicKey(address); + break; + case "basic": + default: + pubKey = chainScore.getBTPPublicKey(address, DSA); + } System.out.println("getPublicKey:" + StringUtil.bytesToHex(pubKey)); + if (pubKey == null) { pubKey = validatorWallet.getPublicKey(); System.out.println("setBTPPublicKey:" + StringUtil.bytesToHex(pubKey)); - chainScore.setBTPPublicKey(DSA, pubKey); + switch (platform) { + case "icon": + chainScore.setPRepNodePublicKey(pubKey); + break; + case "basic": + default: + chainScore.setBTPPublicKey(DSA, pubKey); + } } } - - }