Skip to content

Commit ca94f4c

Browse files
committed
test: Fix test code
1 parent eda1ef3 commit ca94f4c

File tree

21 files changed

+150
-261
lines changed

21 files changed

+150
-261
lines changed

test/Libplanet.Crypto.Secp256k1.Tests/Libplanet.Crypto.Secp256k1.Tests.csproj

Lines changed: 0 additions & 20 deletions
This file was deleted.

test/Libplanet.Crypto.Secp256k1.Tests/Secp256k1CryptoBackendTest.cs

Lines changed: 0 additions & 53 deletions
This file was deleted.

test/Libplanet.Explorer.Tests/GraphTypes/TransactionTypeTest.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public async Task Query()
3333
id
3434
nonce
3535
signer
36-
publicKey
3736
updatedAddresses
3837
signature
3938
timestamp
@@ -51,9 +50,6 @@ await ExecuteQueryAsync(
5150
(Dictionary<string, object>)((ExecutionNode) result.Data!)?.ToValue()!;
5251
Assert.Null(result.Errors);
5352
Assert.Equal(transaction.Id.ToHex(), resultData["id"]);
54-
Assert.Equal(
55-
ByteUtil.Hex(transaction.PublicKey.Format(true)),
56-
resultData["publicKey"]);
5753
Assert.Equal(transaction.Signer.ToString(), resultData["signer"]);
5854
Assert.Equal(ByteUtil.Hex(transaction.Signature), resultData["signature"]);
5955
Assert.Equal(transaction.Nonce, resultData["nonce"]);

test/Libplanet.Net.Tests/AppProtocolVersionTest.cs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,11 @@ public class AppProtocolVersionTest
2323
signer: SignerFixture.Address,
2424
signature: new byte[]
2525
{
26-
0x30, 0x45, 0x02, 0x21, 0x00, 0x89, 0x95, 0x9c, 0x59, 0x25, 0x83, 0x4e,
27-
0xbc, 0x45, 0x59, 0xd7, 0x9b, 0xca, 0x82, 0x4a, 0x69, 0x20, 0xe5, 0x18,
28-
0xf0, 0xc5, 0xad, 0xe2, 0xb9, 0xa3, 0xa3, 0xb3, 0x29, 0xbb, 0xa3, 0x3d,
29-
0xd8, 0x02, 0x20, 0x1d, 0xcb, 0x88, 0xa1, 0x3a, 0x3c, 0x19, 0x2d, 0xe1,
30-
0x9e, 0x39, 0xf6, 0x58, 0x05, 0xd4, 0x06, 0xbf, 0xb2, 0x93, 0xd1, 0x64,
31-
0x85, 0x75, 0xa8, 0xa2, 0xcb, 0x9f, 0x95, 0xd9, 0x90, 0xb9, 0x51,
26+
0xc6, 0xc8, 0xc1, 0x78, 0x52, 0xc6, 0x21, 0x0d, 0x97, 0xd7, 0x8b, 0xdd, 0xf1, 0x26,
27+
0x49, 0x94, 0x1b, 0x80, 0x8b, 0x6a, 0x3a, 0x90, 0xad, 0x62, 0x83, 0x3e, 0xf4, 0x2a,
28+
0x22, 0x2b, 0xc8, 0xf4, 0x07, 0x5e, 0xbe, 0x87, 0x32, 0x57, 0x34, 0xa9, 0x77, 0x1c,
29+
0x3c, 0x87, 0x24, 0x39, 0x4a, 0x71, 0xcc, 0x5f, 0xaa, 0x8b, 0x07, 0x96, 0xbf, 0xb2,
30+
0x7c, 0xf7, 0x7f, 0x11, 0xd1, 0x07, 0x49, 0xa2, 0x1c,
3231
}.ToImmutableArray()
3332
);
3433

@@ -218,15 +217,14 @@ public void Token()
218217
{
219218
var expected =
220219
"1/271e00B29aeB93B2F4e30ECbebA4f72ac02f72b4/" +
221-
"MEUCIQCJlZxZJYNOvEVZ15vKgkppIOUY8MWt4rmjo7Mpu6M92AIgHcuIoTo8GS3hnjn2WAXUBr+yk9Fk" +
222-
"hXWoosufldmQuVE=";
220+
"xsjBeFLGIQ2X14vd8SZJlBuAi2o6kK1igz70KiIryPQHXr6HMlc0qXccPIckOUpxzF+qiweWv7J8938R" +
221+
"0QdJohw=";
223222
Assert.Equal(expected, ValidClaimFixture.Token);
224223

225224
expected =
226225
"123/271e00B29aeB93B2F4e30ECbebA4f72ac02f72b4/" +
227226
"MEQCIAhd1E0voVfgAcpvypiNeh0TdMvJJso7w98UPTfirQSIAiAW1K5yQjFj6XOZUAu5GUmh8rtjIJla" +
228-
"d9IV.b1ZmexcUQ==/" +
229-
"dTM6Zm9v";
227+
"d9IV.b1ZmexcUQ==/dTM6Zm9v";
230228
Assert.Equal(expected, ValidClaimWExtraFixture.Token);
231229
}
232230

@@ -237,17 +235,16 @@ public void FromToken()
237235
ValidClaimFixture,
238236
AppProtocolVersion.FromToken(
239237
"1/271e00B29aeB93B2F4e30ECbebA4f72ac02f72b4/" +
240-
"MEUCIQCJlZxZJYNOvEVZ15vKgkppIOUY8MWt4rmjo7Mpu6M92AIgHcuIoTo8GS3hnjn2WAXUBr+y" +
241-
"k9FkhXWoosufldmQuVE="
238+
"xsjBeFLGIQ2X14vd8SZJlBuAi2o6kK1igz70KiIryPQHXr6HMlc0qXccPIckOUpxzF+qiweWv7J8" +
239+
"938R0QdJohw="
242240
)
243241
);
244242
Assert.Equal(
245243
ValidClaimWExtraFixture,
246244
AppProtocolVersion.FromToken(
247245
"123/271e00B29aeB93B2F4e30ECbebA4f72ac02f72b4/" +
248246
"MEQCIAhd1E0voVfgAcpvypiNeh0TdMvJJso7w98UPTfirQSIAiAW1K5yQjFj6XOZUAu5GUmh8rtj" +
249-
"IJlad9IV.b1ZmexcUQ==/" +
250-
"dTM6Zm9v"
247+
"IJlad9IV.b1ZmexcUQ==/dTM6Zm9v"
251248
)
252249
);
253250

test/Libplanet.Net.Tests/Messages/MessageTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public void GetId()
118118
var message = new BlockHeaderMsg(genesis.Hash, genesis.Header);
119119
Assert.Equal(
120120
new MessageId(ByteUtil.ParseHex(
121-
"70b510a01be2ac0fbe87f69000e2d2b07cbd4dacf45b644c09f16f1490aafba4")),
121+
"e1acbdc4d0cc1eb156cec60d0bf6d40fae3a90192e95719b12e6ee944c71b742")),
122122
message.Id);
123123
}
124124

test/Libplanet.Tests/Action/ActionEvaluatorTest.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -529,9 +529,9 @@ DumbAction MakeAction(Address address, char identifier, Address? transferTo = nu
529529
// have to be updated, since the order may change due to different PreEvaluationHash.
530530
(int TxIdx, int ActionIdx, string[] UpdatedStates, Address Signer)[] expectations =
531531
{
532-
(1, 0, new[] { null, null, "C", null, null }, _txFx.Address2), // Adds "A"
533-
(0, 0, new[] { "A", null, "C", null, null }, _txFx.Address1), // Adds "B"
534-
(0, 1, new[] { "A", "B", "C", null, null }, _txFx.Address1), // Adds "C"
532+
(0, 0, new[] { "A", null, null, null, null }, _txFx.Address1), // Adds "A"
533+
(0, 1, new[] { "A", "B", null, null, null }, _txFx.Address1), // Adds "B"
534+
(1, 0, new[] { "A", "B", "C", null, null }, _txFx.Address2), // Adds "C"
535535
};
536536

537537
#if DEBUG
@@ -679,8 +679,8 @@ DumbAction MakeAction(Address address, char identifier, Address? transferTo = nu
679679
expectations = new (int TxIdx, int ActionIdx, string[] UpdatedStates, Address Signer)[]
680680
{
681681
(0, 0, new[] { "A,D", "B", "C", null, null }, _txFx.Address1),
682-
(2, 0, new[] { "A,D", "B", "C", null, "F" }, _txFx.Address3),
683-
(1, 0, new[] { "A,D", "B", "C", "E", "F" }, _txFx.Address2),
682+
(1, 0, new[] { "A,D", "B", "C", "E", null }, _txFx.Address2),
683+
(2, 0, new[] { "A,D", "B", "C", "E", "F" }, _txFx.Address3),
684684
};
685685

686686
#if DEBUG
@@ -1684,10 +1684,10 @@ internal class OrderTxsForEvaluationData : IEnumerable<object[]>
16841684
// Spec for protocol version < 3.
16851685
public List<string> OrderedAddressesV0 = new List<string>
16861686
{
1687-
"0xB0ea0018Ab647418FA81c384194C9167e6A3C925",
1688-
"0x1d2B31bF9A2CA71051f8c66E1C783Ae70EF32798",
1689-
"0xfcbfa4977B2Fc7A608E4Bd2F6F0D6b27C0a4cd13",
16901687
"0xc2A86014073D662a4a9bFCF9CB54263dfa4F5cBc",
1688+
"0xfcbfa4977B2Fc7A608E4Bd2F6F0D6b27C0a4cd13",
1689+
"0x1d2B31bF9A2CA71051f8c66E1C783Ae70EF32798",
1690+
"0xB0ea0018Ab647418FA81c384194C9167e6A3C925",
16911691
"0x921Ba81C0be280C8A2faed79E14aD2a098874759",
16921692
};
16931693

test/Libplanet.Tests/Blocks/BlockContentTest.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ public void Transactions()
7272
new TxSigningMetadata(key.PublicKey, nonce: 0)
7373
),
7474
signature: ByteUtil.ParseHexToImmutable(
75-
"304402202a8324c83390b1fe0fdd4014056a049bc02ca059369ef62145fe574cb31224f" +
76-
"d022073bf8a48403cf46f5fa63f26f3e8ef4db8ef1d841684856da63d9b7eeb91759a"
75+
"cd51a992907121083ae2da9b39f94063fe5eb1bb91bb96dc83ced6add8370fe36" +
76+
"394d6db0fca60ebfe40284e4c4cf6096cf5aa4e18bdc5d4f732033ea692e7521c"
7777
)
7878
);
7979
var txs = new[] { tx2, Block1Tx0, Block1Tx1 }.OrderBy(tx => tx.Id).ToImmutableList();
@@ -106,11 +106,11 @@ public void TransactionsWithDuplicateNonce()
106106
actions: TxActionList.Empty,
107107
maxGasPrice: null,
108108
gasLimit: null),
109-
new TxSigningMetadata(Block1Tx1.PublicKey, nonce: 1L)
109+
new TxSigningMetadata(Block1Tx1.Signer, nonce: 1L)
110110
),
111111
signature: ByteUtil.ParseHexToImmutable(
112-
"304502210099e580e8599acf0b26ad0a80315f2d488703ffde01e9449b4bf399593b8cc" +
113-
"e63022002feb21bf0e4d76d25d17c8c1c4fbb3dfbda986e0693f984fbb302183ab7ece1"
112+
"271c43e8c1a54c59686a49f13f1279765dd26a40a7b5e649a7dbf938bbcef3bf5" +
113+
"e1d6be5b456506873fbd9d3e5b07a5f72bfeac19774cd8f8c7fd4f4f73abb6d1b"
114114
)
115115
);
116116
var txs = new[] { Block1Tx0, Block1Tx1, dupTx1 }.OrderBy(tx => tx.Id).ToArray();
@@ -127,9 +127,9 @@ public void TransactionsWithDuplicateNonce()
127127
evidenceHash: null),
128128
transactions: txs,
129129
evidence: evs));
130-
Assert.Equal(Block1Tx1.Id, e.TxId);
130+
Assert.Equal(dupTx1.Id, e.TxId);
131131
Assert.Equal(2L, e.ExpectedNonce);
132-
Assert.Equal(Block1Tx1.Nonce, e.ImproperNonce);
132+
Assert.Equal(dupTx1.Nonce, e.ImproperNonce);
133133
}
134134

135135
[Fact]
@@ -144,14 +144,14 @@ public void TransactionsWithMissingNonce()
144144
actions: TxActionList.Empty,
145145
maxGasPrice: null,
146146
gasLimit: null),
147-
new TxSigningMetadata(Block1Tx1.PublicKey, nonce: 3L)
147+
new TxSigningMetadata(Block1Tx1.Signer, nonce: 3L)
148148
),
149149
signature: ByteUtil.ParseHexToImmutable(
150-
"3045022100bfdf79427028efea9449ad46fbf46d5a806694aa5bbab1a01f4c76b21acd" +
151-
"cb16022057c851a01dd74797121385ccfc81e7b33842941189154b4d46d05e891a28e3eb"
150+
"299543707e52a2ba0a20f6dfd306ca6a87c8f0567134c83f1a078af064547b9f4" +
151+
"72f3e6d2bb88c7e7cc46a6d70017117f5cb75fbb5cbd7239e042d1273072e861c"
152152
)
153153
);
154-
var txs = new[] { Block1Tx0, Block1Tx1, dupTx1 }.OrderBy(tx => tx.Id).ToArray();
154+
var txs = new[] { Block1Tx1, Block1Tx0, dupTx1 }.OrderBy(tx => tx.Id).ToArray();
155155
var evs = Array.Empty<EvidenceBase>();
156156
InvalidTxNonceException e = Assert.Throws<InvalidTxNonceException>(
157157
() => new BlockContent(
@@ -215,9 +215,9 @@ public void TxHash()
215215
{
216216
var expected = new HashDigest<SHA256>(new byte[]
217217
{
218-
0x65, 0x46, 0x98, 0xd3, 0x4b, 0x6d, 0x9a, 0x55, 0xb0, 0xc9, 0x3e,
219-
0x4f, 0xfb, 0x26, 0x39, 0x27, 0x83, 0x24, 0x86, 0x8c, 0x91, 0x96,
220-
0x5b, 0xc5, 0xf9, 0x6c, 0xb3, 0x07, 0x1d, 0x69, 0x03, 0xa0,
218+
0x9d, 0x64, 0x57, 0xe7, 0xbd, 0xc4, 0xb1, 0x9d, 0x1f, 0x34, 0x1c, 0x45, 0xc7, 0x87,
219+
0xcf, 0x80, 0xa1, 0x7c, 0x51, 0x4d, 0xa1, 0x0d, 0x70, 0x26, 0x06, 0xcc, 0x41, 0xf2,
220+
0x33, 0x87, 0xba, 0xdb,
221221
});
222222
AssertBytesEqual(expected, Block1Content.TxHash);
223223
Assert.Null(GenesisContentPv0.TxHash);

test/Libplanet.Tests/Blocks/BlockMetadataTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public void MakeCandidateData()
129129
.Add("protocol_version", BlockMetadata.CurrentProtocolVersion)
130130
.Add(
131131
"transaction_fingerprint",
132-
ParseHex("3d8e87977b1142863435b9385657e69557df8951a0698e9719f7d06c5fb8db1f")
132+
ParseHex("5553c7f03ca10f7f9a58b051f65e1d35d52c28d658f3316545075dd07303cd71")
133133
)
134134
.Add(
135135
"evidence_hash",
@@ -151,7 +151,7 @@ public void MakeCandidateData()
151151
)
152152
.Add(
153153
"transaction_fingerprint",
154-
ParseHex("654698d34b6d9a55b0c93e4ffb2639278324868c91965bc5f96cb3071d6903a0")
154+
ParseHex("9d6457e7bdc4b19d1f341c45c787cf80a17c514da10d702606cc41f23387badb")
155155
)
156156
.Add("protocol_version", BlockMetadata.CurrentProtocolVersion)
157157
.Add(
@@ -178,7 +178,7 @@ public void MakeCandidateDataPv1()
178178
.Add(
179179
"transaction_fingerprint",
180180
ParseHex(
181-
"654698d34b6d9a55b0c93e4ffb2639278324868c91965bc5f96cb3071d6903a0"
181+
"9d6457e7bdc4b19d1f341c45c787cf80a17c514da10d702606cc41f23387badb"
182182
)
183183
)
184184
.Add(
@@ -207,7 +207,7 @@ public void DerivePreEvaluationHash()
207207

208208
HashDigest<SHA256> hash = GenesisMetadata.DerivePreEvaluationHash();
209209
AssertBytesEqual(
210-
FromHex("9ff328716814fed03de454dfc0a9d9aeb0077ad0c393513bf29895a45ded13aa"),
210+
FromHex("79c69838bb150cd31c77bf0a10db1f088dbd1509613b33db1081f2b39a6974e0"),
211211
hash.ByteArray);
212212
}
213213

test/Libplanet.Tests/Blocks/PreEvaluationBlockHeaderTest.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void MakeCandidateData()
6969
.Add("state_root_hash", default(HashDigest<SHA256>).ByteArray)
7070
.Add(
7171
"transaction_fingerprint",
72-
ParseHex("3d8e87977b1142863435b9385657e69557df8951a0698e9719f7d06c5fb8db1f")
72+
ParseHex("5553c7f03ca10f7f9a58b051f65e1d35d52c28d658f3316545075dd07303cd71")
7373
)
7474
.Add(
7575
"evidence_hash",
@@ -102,7 +102,7 @@ public void MakeCandidateData()
102102
.Add(
103103
"transaction_fingerprint",
104104
ParseHex(
105-
"654698d34b6d9a55b0c93e4ffb2639278324868c91965bc5f96cb3071d6903a0"
105+
"9d6457e7bdc4b19d1f341c45c787cf80a17c514da10d702606cc41f23387badb"
106106
)
107107
)
108108
.Add(
@@ -181,8 +181,8 @@ public void VerifySignature()
181181

182182
// Same as block1.MakeSignature(_contents.Block1Key, arbitraryHash)
183183
ImmutableArray<byte> validSig = ByteUtil.ParseHexToImmutable(
184-
"3045022100f975e902971092f16dbbb1fe6b7c956de648a8cd62346dbadc07e5fca4ce3" +
185-
"07a02200987a349f0763efd0448659ed66c6bd0ad0971dd57fbb89c672aed592fbd70d6");
184+
"e50d22ff371bc82a57e0bf821d1628b00689b028f21bd1148c9c1851fa5e63746" +
185+
"6d120d3fbfc0d3a42fc2825837bdc0ae058d5e75e4875f32420f0629a7af1e51b");
186186
AssertBytesEqual(
187187
validSig,
188188
block1.MakeSignature(_contents.Block1Key, arbitraryHash));
@@ -215,22 +215,22 @@ public void DeriveBlockHash()
215215
_contents.GenesisMetadata,
216216
_contents.GenesisMetadata.DerivePreEvaluationHash());
217217
AssertBytesEqual(
218-
fromHex("d790aa3b2d985d58e6fe6547336ca9d2bfdb749a27cd58a17dbfd0c6880da8e3"),
218+
fromHex("c08f58b8ed3e8c50cf7d3415191dd97dda4438d459eb8da93cb1e1c7449716c0"),
219219
genesis.DeriveBlockHash(default, null)
220220
);
221221
AssertBytesEqual(
222-
fromHex("47b5227dfdd99af4faf9ae9e82ef3b615063179d275081eae4c122685bbf7dcb"),
222+
fromHex("85864e96e55112ba7a93923802cdfa419fad920f511f458ee33ddb0b51cce275"),
223223
genesis.DeriveBlockHash(
224224
default,
225225
genesis.MakeSignature(_contents.GenesisKey, default)
226226
)
227227
);
228228
AssertBytesEqual(
229-
fromHex("2c45bb52e4c7d79caa28da9b63ec0f492262836c975bfa5bb27f62e96f2aad99"),
229+
fromHex("d4f75f2a59ad25469abf5499d1458cad0b4390087b2c81318cacc3b495e5692a"),
230230
genesis.DeriveBlockHash(arbitraryHash, null)
231231
);
232232
AssertBytesEqual(
233-
fromHex("e985fcdce3f73dee90a4eaec9399283f856bb6f9326e4300bbe1d6126ff7ad55"),
233+
fromHex("d22ae31924a68ac6d17e894fea437c3861c8cc2d1e24a657a2ef3e4331b6f639"),
234234
genesis.DeriveBlockHash(
235235
arbitraryHash,
236236
genesis.MakeSignature(_contents.GenesisKey, arbitraryHash))
@@ -240,19 +240,19 @@ public void DeriveBlockHash()
240240
_contents.Block1Metadata,
241241
_contents.Block1Metadata.DerivePreEvaluationHash());
242242
AssertBytesEqual(
243-
fromHex("ade696a646c9e4321cc90160807cba3d15d7cd28556d2dfb4103e8730a46038c"),
243+
fromHex("b0b8bc62b85baa02cf941a5ea33db60ee890b098a197377af5ece82afadb4bb2"),
244244
block1.DeriveBlockHash(default, null)
245245
);
246246
AssertBytesEqual(
247-
fromHex("b3157a151d2168653e21ffc850f9d1a96bca6310275cccbeb9bd705f67c2e1c9"),
247+
fromHex("31c8d60dcbff7a8a119ed25f239a829116f079074cf274613f599cc6dfe835d6"),
248248
block1.DeriveBlockHash(default, block1.MakeSignature(_contents.Block1Key, default))
249249
);
250250
AssertBytesEqual(
251-
fromHex("3fd4ee37ed2fc5dae5a9533984f06b3975e176bdaa70689a3c14acd8b4ea384d"),
251+
fromHex("6ce7bfd2a8d35876f7f0e1dfe974b206e8ac8ceee5cca3691350354bb2c08a84"),
252252
block1.DeriveBlockHash(arbitraryHash, null)
253253
);
254254
AssertBytesEqual(
255-
fromHex("83ceb4d1e5bbc385daaebfd044a5e4ba65bf1d8b63ef0aabe4d68fc5642b4516"),
255+
fromHex("1026b747d6ad2f0096ca2aed76165814c18522693edac1f752a8e81fae569820"),
256256
block1.DeriveBlockHash(
257257
arbitraryHash, block1.MakeSignature(_contents.Block1Key, arbitraryHash)
258258
)

0 commit comments

Comments
 (0)