Skip to content

Commit 989f3db

Browse files
authored
fix 3 test cases (#7060)
1 parent a977a30 commit 989f3db

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

‎framework/src/test/java/org/tron/core/db/AccountIdIndexStoreTest.java‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ public class AccountIdIndexStoreTest extends BaseTest {
2525
private static final byte[] ACCOUNT_ADDRESS_TWO = randomBytes(16);
2626
private static final byte[] ACCOUNT_ADDRESS_THREE = randomBytes(16);
2727
private static final byte[] ACCOUNT_ADDRESS_FOUR = randomBytes(16);
28-
private static final byte[] ACCOUNT_NAME_ONE = randomBytes(6);
29-
private static final byte[] ACCOUNT_NAME_TWO = randomBytes(6);
30-
private static final byte[] ACCOUNT_NAME_THREE = randomBytes(6);
31-
private static final byte[] ACCOUNT_NAME_FOUR = randomBytes(6);
32-
private static final byte[] ACCOUNT_NAME_FIVE = randomBytes(6);
28+
// Random bytes can collide after UTF-8 decoding and case normalization of account IDs.
29+
private static final byte[] ACCOUNT_NAME_ONE = "account1".getBytes(StandardCharsets.UTF_8);
30+
private static final byte[] ACCOUNT_NAME_TWO = "account2".getBytes(StandardCharsets.UTF_8);
31+
private static final byte[] ACCOUNT_NAME_THREE = "account3".getBytes(StandardCharsets.UTF_8);
32+
private static final byte[] ACCOUNT_NAME_FOUR = "account4".getBytes(StandardCharsets.UTF_8);
33+
private static final byte[] ACCOUNT_NAME_FIVE = "account5".getBytes(StandardCharsets.UTF_8);
3334
private static final Locale TURKISH = Locale.forLanguageTag("tr");
3435
@Resource
3536
private AccountIdIndexStore accountIdIndexStore;

‎framework/src/test/java/org/tron/core/net/messagehandler/TransactionsMsgHandlerTest.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import org.tron.core.net.peer.Item;
5050
import org.tron.core.net.peer.PeerConnection;
5151
import org.tron.core.net.service.adv.AdvService;
52+
import org.tron.core.net.service.fetchblock.FetchBlockService;
5253
import org.tron.core.net.service.sync.SyncService;
5354
import org.tron.p2p.connection.Channel;
5455
import org.tron.protos.Protocol;
@@ -591,6 +592,7 @@ private void assertDisconnectRecovery(boolean announced, boolean busy) throws Ex
591592
List<PeerConnection> activePeers = new ArrayList<>(Collections.singletonList(source));
592593
Mockito.when(delegate.getActivePeer()).thenReturn(activePeers);
593594
ReflectUtils.setFieldValue(adv, "tronNetDelegate", delegate);
595+
ReflectUtils.setFieldValue(adv, "fetchBlockService", Mockito.mock(FetchBlockService.class));
594596
setField(handler, "tronNetDelegate", delegate);
595597
setField(handler, "advService", adv);
596598
setField(handler, "chainBaseManager", Mockito.mock(ChainBaseManager.class));

‎framework/src/test/java/org/tron/core/net/services/RelayServiceTest.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,12 @@ private void assertHelloAuthentication(RelayService relay, long timestamp, ByteS
452452
Channel channel = mock(Channel.class);
453453
Mockito.when(channel.getInetSocketAddress()).thenReturn(socketAddress);
454454
Mockito.when(channel.getInetAddress()).thenReturn(socketAddress.getAddress());
455+
Protocol.HelloMessage.BlockId blockId = Protocol.HelloMessage.BlockId.newBuilder()
456+
.setHash(Sha256Hash.ZERO_HASH.getByteString()).build();
455457
HelloMessage message = new HelloMessage(Protocol.HelloMessage.newBuilder()
458+
.setGenesisBlockId(blockId)
459+
.setSolidBlockId(blockId)
460+
.setHeadBlockId(blockId)
456461
.setTimestamp(timestamp).setAddress(address).setSignature(signature).build().toByteArray());
457462

458463
Assert.assertFalse(TronNetService.getP2pConfig().getTrustNodes()

0 commit comments

Comments
 (0)