mirror of
https://github.com/XRPLF/rippled.git
synced 2026-08-22 23:00:55 +00:00
feat: Porting wasm host function tests to new design
This commit is contained in:
39
src/tests/libxrpl/tx/wasm/host_functions/VaultKeylet.cpp
Normal file
39
src/tests/libxrpl/tx/wasm/host_functions/VaultKeylet.cpp
Normal 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
|
||||
Reference in New Issue
Block a user