feat: Porting wasm host function tests to new design

This commit is contained in:
TimothyBanks
2026-08-15 19:41:32 -04:00
parent d469fc2cdf
commit e863db5061
33 changed files with 1661 additions and 1019 deletions

View File

@@ -0,0 +1,39 @@
#include <xrpl/protocol/AccountID.h>
#include <xrpl/protocol/Indexes.h>
#include <xrpl/protocol/SeqProxy.h>
#include <xrpl/tx/wasm/WasmCommon.h>
#include <gtest/gtest.h>
#include <helpers/Account.h>
#include <helpers/TxTest.h>
#include <tx/wasm/RealHostFixture.h>
#include <expected>
#include <iterator>
namespace xrpl::test {
struct VaultKeyletImpl : WasmImplTest
{
};
TEST_F(VaultKeyletImpl, MatchesVaultFunction)
{
auto const owner = Account{"owner"};
ledger.createAccount(owner, XRP(1000));
auto const expected = keylet::vault(owner.id(), SeqProxy::rawSequence(1u));
auto const expectedBytes = Bytes{std::begin(expected.key), std::end(expected.key)};
auto const result = host().vaultKeylet(owner.id(), 1u);
ASSERT_TRUE(result.has_value());
EXPECT_EQ(*result, expectedBytes);
}
TEST_F(VaultKeyletImpl, InvalidAccount)
{
auto result = host().vaultKeylet(AccountID{}, 1u);
ASSERT_TRUE(!result.has_value());
EXPECT_EQ(result.error(), HostFunctionError::InvalidAccount);
}
} // namespace xrpl::test