Skip to content

Commit 356286b

Browse files
committed
Test trust() on native SAC
1 parent baa06b4 commit 356286b

3 files changed

Lines changed: 17 additions & 8 deletions

File tree

src/transactions/test/InvokeHostFunctionTests.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,9 @@ TEST_CASE("Native stellar asset contract",
505505
REQUIRE(entry.current().data.account().balance == createAmount);
506506
}
507507

508+
// Calling trust on the native asset should fail
509+
REQUIRE(!client.trust(a2));
510+
508511
// Transferring below minimum should fail for a non-existent account
509512
auto newAccKey2 = SecretKey::pseudoRandomForTesting();
510513
auto newAccPub2 = newAccKey2.getPublicKey();

src/transactions/test/SorobanTxTestUtils.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1990,9 +1990,15 @@ AssetContractTestClient::trust(TestAccount& addr)
19901990
LedgerKey accountKey(ACCOUNT);
19911991
accountKey.account().accountID = addr.getPublicKey();
19921992

1993-
auto spec = defaultSpec()
1994-
.setReadWriteFootprint({trustlineKey, accountKey})
1995-
.extendReadOnlyFootprint({makeIssuerKey(mAsset)});
1993+
auto spec = defaultSpec();
1994+
// If this is the native asset, we expect the tx to fail, but we still want
1995+
// to be able to test that failure, so make sure the tx that is built passes
1996+
// initial validation.
1997+
if (mAsset.type() != ASSET_TYPE_NATIVE)
1998+
{
1999+
spec = spec.setReadWriteFootprint({trustlineKey, accountKey})
2000+
.extendReadOnlyFootprint({makeIssuerKey(mAsset)});
2001+
}
19962002

19972003
auto invocation = mContract.prepareInvocation("trust", {addrVal}, spec)
19982004
.withAuthorizedTopCall();

test-tx-meta-baseline-next/InvokeHostFunctionTests.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@
5151
[
5252
"+cR3oq2qY0I=",
5353
"v/UMJBmXfpU=",
54-
"85yMEwwwc2M=",
55-
"a1q2UiYASYk=",
56-
"eoffsMU55dU=",
57-
"7oyuQYJsb0E=",
58-
"4P+9B/v0HWY="
54+
"c5hMI0Elm+M=",
55+
"Hy46FpEBO/4=",
56+
"Y47MsGv0nS8=",
57+
"VW84T3660GI=",
58+
"15WZmVivTk4="
5959
],
6060
"Soroban authorization" :
6161
[

0 commit comments

Comments
 (0)