Skip to content

Commit 61ac3aa

Browse files
committed
Fixup sloppy merge
1 parent 4f30d82 commit 61ac3aa

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

docs/build/guides/testing/unit-tests.mdx

+9
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,13 @@ The `Env` created at the beginning of the test is not a simulation of the Soroba
7171

7272
:::
7373

74+
It's a simple test, but it's a complete test. There's a full environment setup, used, and torn down in the test, and it happens fast. The Rust test harness runs all the tests for a contract in parallel and each will have its own isolated contract environment.
75+
76+
Most tests, even integration tests and fuzz tests, will look very similar to this unit test. They'll do four things:
77+
78+
1. Create an environment, the `Env`.
79+
2. Register the contract(s) to be tested.
80+
3. Invoke functions using a client.
81+
4. Assert the outcome.
82+
7483
[increment contract]: https://github.com/stellar/soroban-examples/blob/main/increment/src/lib.rs

docs/data/rpc/api-reference/methods/getLedgerEntries.mdx

+2-8
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,6 @@ function getLedgerKeyWasmId(
265265

266266
Now, finally we have a `LedgerKey` that correspond to the Wasm byte-code that has been deployed under the `contractId` we started out with so very long ago. This `LedgerKey` can be used in a final request to `getLedgerEntries`. In that response we will get a `LedgerEntryData` corresponding to a `ContractCodeEntry` which will contain the actual, deployed, real-life contract byte-code:
267267

268-
<CodeExample>
269-
270268
```typescript
271269
const theHashData: xdr.ContractDataEntry = await getLedgerEntries(
272270
getLedgerKeyContractCode("C..."),
@@ -277,14 +275,10 @@ const theCode: Buffer = await getLedgerEntries(getLedgerKeyWasmId(theHashData))
277275
.code();
278276
```
279277

280-
</CodeExample>
281-
282278
## Actually fetching the ledger entry data
283279

284280
Once we've learned to _build_ and _parse_ these (which we've done above at length), the process for actually fetching them is always identical. If you know the type of key you fetched, you apply the accessor method accordingly once you've received them from the `getLedgerEntries` method:
285281

286-
<CodeExample>
287-
288282
```typescript
289283
const s = new Server("https://soroban-testnet.stellar.org");
290284

@@ -296,6 +290,8 @@ const contractData = keys.entries[2].contractData();
296290
const contractCode = keys.entries[1].contractCode();
297291
```
298292

293+
Now, finally we have a `LedgerKey` that correspond to the Wasm byte-code that has been deployed under the `ContractId` we started out with so very long ago. This `LedgerKey` can be used in a final request to the Stellar-RPC endpoint.
294+
299295
```json
300296
{
301297
"jsonrpc": "2.0",
@@ -311,8 +307,6 @@ const contractCode = keys.entries[1].contractCode();
311307
}
312308
```
313309

314-
</CodeExample>
315-
316310
Then you can inspect them accordingly. Each of the above entries follows the XDR for that `LedgerEntryData` structure precisely. For example, the `AccountEntry` is in [`Stellar-ledger-entries.x#L191`](https://github.com/stellar/stellar-xdr/blob/529d5176f24c73eeccfa5eba481d4e89c19b1181/Stellar-ledger-entries.x#L191) and you can use `.seqNum()` to access its current sequence number, as we've shown. In JavaScript, you can see the appropriate methods in the [type definition](https://github.com/stellar/js-stellar-base/blob/6930a70d7fbde675514b5933baff605d97453ba7/types/curr.d.ts#L3034).
317311

318312
## Viewing and understanding XDR

0 commit comments

Comments
 (0)