Skip to content

Commit

Permalink
[fix][*][0.2.0]: fix unit test cases (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
zouxyan committed Jan 2, 2024
1 parent b658044 commit 830dcde
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,10 @@
import com.alipay.antchain.bridge.commons.core.base.CrossChainDomain;
import com.alipay.antchain.bridge.commons.core.base.ObjectIdentityType;
import lombok.SneakyThrows;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.*;
import org.junit.runners.MethodSorters;

@Ignore
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class BifBCDNSClientTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ public void testCrossChainDomain() {
new CrossChainDomain(OVERSIZE_DOMAIN);
});

Assert.assertThrows(AntChainBridgeBaseException.class, () -> {
new CrossChainDomain("");
});

new CrossChainDomain("test");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public class AuthMessageTest {

private static final String RAW_MESSAGE_HEX_PAYLOAD_V1_MOD32 = RAW_MESSAGE_HEX_V1_MOD32.substring(64, 128) + RAW_MESSAGE_HEX_V1_MOD32.substring(0, 64);

private static final String RAW_MESSAGE_HEX_V2 = "97943daf4ed8cb477ef2e0048f5baede046f6bf797943daf4ed8cb477ef2e0048f5baede046f6bf700000028000000010000000000000000000000007ef2e0048f5baede046f6bf797943daf4ed8cb4700000002";
private static final String RAW_MESSAGE_HEX_V2 = "97943daf4ed8cb477ef2e0048f5baede046f6bf797943daf4ed8cb477ef2e0048f5baede046f6bf70000002802000000010000000000000000000000007ef2e0048f5baede046f6bf797943daf4ed8cb4700000002";

private static final String RAW_MESSAGE_HEX_ID_V2 = RAW_MESSAGE_HEX_V2.substring(96, 160);
private static final String RAW_MESSAGE_HEX_ID_V2 = RAW_MESSAGE_HEX_V2.substring(98, 162);

private static final String RAW_MESSAGE_HEX_PAYLOAD_V2 = RAW_MESSAGE_HEX_V2.substring(0, 80);

Expand Down Expand Up @@ -84,22 +84,24 @@ public void testAuthMessageV1Encode() {
public void testAuthMessageV2Decode() {
byte[] rawMessage = Convert.hexToBytes(RAW_MESSAGE_HEX_V2);

IAuthMessage am = new AuthMessageV2();
AuthMessageV2 am = new AuthMessageV2();
am.decode(rawMessage);

Assert.assertEquals(2, am.getVersion());
Assert.assertEquals(1, am.getUpperProtocol());
Assert.assertEquals(RAW_MESSAGE_HEX_ID_V2, am.getIdentity().toHex());
Assert.assertEquals(40, am.getPayload().length);
Assert.assertEquals(RAW_MESSAGE_HEX_PAYLOAD_V2, HexUtil.encodeHexStr(am.getPayload()));
Assert.assertEquals(AuthMessageTrustLevelEnum.NEGATIVE_TRUST, am.getTrustLevel());
}

@Test
public void testAuthMessageV2Encode() {
AbstractAuthMessage am = new AuthMessageV2();
AuthMessageV2 am = new AuthMessageV2();
am.setUpperProtocol(1);
am.setIdentity(CrossChainIdentity.fromHexStr(RAW_MESSAGE_HEX_ID_V2));
am.setPayload(HexUtil.decodeHex(RAW_MESSAGE_HEX_PAYLOAD_V2));
am.setTrustLevel(AuthMessageTrustLevelEnum.NEGATIVE_TRUST);

Assert.assertEquals(RAW_MESSAGE_HEX_V2, HexUtil.encodeHexStr(am.encode()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
import com.alipay.antchain.bridge.commons.utils.codec.tlv.TLVTypeEnum;
import com.alipay.antchain.bridge.commons.utils.codec.tlv.TLVUtils;
import com.alipay.antchain.bridge.commons.utils.codec.tlv.annotation.TLVField;
import lombok.Getter;
import lombok.Setter;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
Expand Down Expand Up @@ -222,12 +220,18 @@ public void setValue(List<byte[]> value) {
}
}

@Getter
@Setter
public static class TestStringArray {

@TLVField(tag = 1, type = TLVTypeEnum.STRING_ARRAY, order = 0)
List<String> value;

public List<String> getValue() {
return value;
}

public void setValue(List<String> value) {
this.value = value;
}
}

public static class TestRecursiveOuter {
Expand Down

0 comments on commit 830dcde

Please sign in to comment.