Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dangell7 committed Dec 11, 2024
1 parent 697b6b7 commit f6b2ac3
Show file tree
Hide file tree
Showing 4 changed files with 339 additions and 17 deletions.
30 changes: 29 additions & 1 deletion src/test/app/Wildcard_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,38 @@ class Wildcard_test : public beast::unit_test::suite
}
}

void
testSimplePayment(FeatureBitset features)
{
using namespace test::jtx;

testcase("simple payment");

Env env{*this, envconfig(), features};
Account const alice{"alice"};
Account const bob{"bob"};
Account const carol{"carol"};
Account const dave{"dave", KeyType::dilithium};
env.fund(XRP(1000), alice, bob, carol, dave);
env.close();

env(fset(dave, asfForceQuantum));
env(pay(dave, bob, XRP(100)));
env.close();

Json::Value params;
params[jss::ledger_index] = env.current()->seq() - 1;
params[jss::transactions] = true;
params[jss::expand] = true;
auto const jrr = env.rpc("json", "ledger", to_string(params));
std::cout << jrr << std::endl;
}

void
testWithFeats(FeatureBitset features)
{
testWildcardSign(features);
// testWildcardSign(features);
testSimplePayment(features);
}

public:
Expand Down
65 changes: 52 additions & 13 deletions src/test/protocol/PublicKey_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ class PublicKey_test : public beast::unit_test::suite
std::array<PublicKey, 32> keys;

for (std::size_t i = 0; i != keys.size(); ++i)
keys[i] = derivePublicKey(keyType, randomSecretKey());
keys[i] = derivePublicKey(keyType, randomSecretKey(keyType));

for (std::size_t i = 0; i != keys.size(); ++i)
{
Expand Down Expand Up @@ -431,6 +431,54 @@ class PublicKey_test : public beast::unit_test::suite
}

testBase58(KeyType::ed25519);

// testcase("Base58: dilithium");

// {
// auto const pk1 = derivePublicKey(
// KeyType::dilithium,
// generateSecretKey(
// KeyType::dilithium, generateSeed("masterpassphrase")));

// auto const pk2 = parseBase58<PublicKey>(
// TokenType::NodePublic,
// "p9pow2SA5t1GpXJCZiWeWiKjZ4xav57jYgDzAhesVequQt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CrEfwoEg4uhB9PC9QsturSWWV88S1YTtR7pbEbGtEVBgTkcNMSk2XijUJBGC"
// "r83964fMtsbuj9DyqJgQSg1za6cHfgJt9pzmVoCNBRoBLGcsWn8CZAcxUGZkhm"
// "k2nwERPsCci56kV2UEfTKpq4PqUYWmxi2fvbvamqCWv6kQgBA3FLWXu8rXtsa9"
// "vUx2fV1jiVogFRewsxZ3YCdmAVNmt89jb2ECQX4rdEqDXwfWJPxRUY2JD3JSZi"
// "jWpHVqMJiHGu6KgeGvCcGmiqBvYom3D9ACQxA9QGTCdQh4AYYYjSwDabA7nB4A"
// "EVw2v5L7Z2uz76BHXMcWCHu1B3q57kVihrNfKYGDLcscw9TebPKTimZEqV2PB3"
// "h5YA9P9VKgnRKmkFr8qMQRrVR2ekGafMB2PVRmrMLkZkYNx9exE1mvkN7VoD4t"
// "QyRzQNsSh3xJq6PdBYX5KTm5ouw7DVxev4PQUNiHtZVExZGfjykgzoRojvD7s7"
// "64BpWNyyRAU4zyMT5UU1BdtBQQzdMxxZWMsH6LHkX7dahTPkGAEtQn1gPrJdLP"
// "uPtryue9ps2wNpVWT8T1Riw5fXgZ4NHfJb5hRwX95vg1WKXYMttHMBL6Zi7QEf"
// "9VSdrt2qTw3MTG3F4A3uxJhyapzv1XBfxdKUTRbEh3h59CTmxLZauPBKE2QW5a"
// "jDUwoZKv9cV6isLfNe49XYSWa4ger9X3Gfga8xxPrmaxnWeST2qjfUkhuqi44F"
// "v");

// BEAST_EXPECT(pk2);

// BEAST_EXPECT(pk1 == *pk2);
// }

// testBase58(KeyType::dilithium);
}

void
Expand All @@ -453,21 +501,12 @@ class PublicKey_test : public beast::unit_test::suite
BEAST_EXPECT(pk1 == pk3);
}

void
testDilithium()
{
testcase("Dilithium");
BEAST_EXPECT(1 == 1);

}

void
run() override
{
// testBase58();
// testCanonical();
// testMiscOperations();
testDilithium();
testBase58();
testCanonical();
testMiscOperations();
}
};

Expand Down
6 changes: 3 additions & 3 deletions src/test/protocol/SecretKey_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ class SecretKey_test : public beast::unit_test::suite
auto const sk = generateSecretKey(
KeyType::dilithium, generateSeed("masterpassphrase"));
auto const pk = derivePublicKey(KeyType::dilithium, sk);
auto const accId = calcAccountID(pk);
// auto const accId = calcAccountID(pk);
auto sig = sign(pk, sk, makeSlice(data));
BEAST_EXPECT(sig.size() != 0);
BEAST_EXPECT(verify(pk, makeSlice(data), sig, true) == 1);
Expand All @@ -388,7 +388,7 @@ class SecretKey_test : public beast::unit_test::suite
auto const seed = randomSeed();
auto const sk = generateSecretKey(KeyType::dilithium, seed);
auto const pk = derivePublicKey(KeyType::dilithium, sk);
auto const accId = calcAccountID(pk);
// auto const accId = calcAccountID(pk);
auto sig = sign(pk, sk, makeSlice(data));
BEAST_EXPECT(sig.size() != 0);
BEAST_EXPECT(verify(pk, makeSlice(data), sig, true) == 1);
Expand All @@ -398,7 +398,7 @@ class SecretKey_test : public beast::unit_test::suite
{
std::pair<PublicKey, SecretKey> const kp =
randomKeyPair(KeyType::dilithium);
auto const accId = calcAccountID(kp.first);
// auto const accId = calcAccountID(kp.first);
auto sig = sign(kp.first, kp.second, makeSlice(data));
BEAST_EXPECT(sig.size() != 0);
BEAST_EXPECT(verify(kp.first, makeSlice(data), sig, true) == 1);
Expand Down
Loading

0 comments on commit f6b2ac3

Please sign in to comment.