#include #include #include #include #include #include #include #include #include namespace xrpl::test { struct TxNestedArrayLenImpl : RealHostFixture { using RealHostFixture::makeHost; WasmHost makeHost(Account const& acct) { auto assembler = escrowFinishTx(ledger, acct); assembler.build = [inner = std::move(assembler.build)](STObject& obj) { inner(obj); auto memos = STArray{}; memos.push_back(makeMemo(toBytes("hello"))); obj.setFieldArray(sfMemos, memos); }; return makeHost(keylet::account(acct.id()), assembler.type, std::move(assembler.build)); } }; TEST_F(TxNestedArrayLenImpl, MemosLength) { auto const owner = fund("owner"); auto h = makeHost(owner); expectValue(h->getTxNestedArrayLen(FieldLocator{{sfMemos.getCode()}}), 1); } TEST_F(TxNestedArrayLenImpl, CredentialIdsLength) { auto const owner = fund("owner"); auto h = makeHost(owner); expectValue(h->getTxNestedArrayLen(FieldLocator{{sfCredentialIDs.getCode()}}), 1); } TEST_F(TxNestedArrayLenImpl, NonArrayFieldNoArray) { auto const owner = fund("owner"); auto h = makeHost(owner); expectError( h->getTxNestedArrayLen(FieldLocator{{sfAccount.getCode()}}), HostFunctionError::NoArray); } TEST_F(TxNestedArrayLenImpl, MissingFieldNotFound) { auto const owner = fund("owner"); auto h = makeHost(owner); expectError( h->getTxNestedArrayLen(FieldLocator{{sfSigners.getCode()}}), HostFunctionError::FieldNotFound); } } // namespace xrpl::test