Skip to content

Commit 755aa8e

Browse files
authored
🖌️ Minor publishing code syntax (#1099)
* ⌨️ Optimize `nginx` line spacing * Fix misc go change * 🐍 Python spacing, misc flow I like adding some space to seperate out the caller base object with the local variable for ease of visual parsing * 🤖 ran the prettier script * 🐜 pass compilation checks (sync)
1 parent ce8e866 commit 755aa8e

2 files changed

Lines changed: 57 additions & 53 deletions

File tree

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Unit tests are small tests that test one piece of functionality within a contrac
99

1010
## How to Write Unit Tests
1111

12-
The following is an example of a unit test, written to test the [increment contract]. The contract has an `increment` function, that increases a counter value by one on every invocation. The following test invokes that contract's function several times, and checks that the value increases by one.
12+
The following is an example of a unit test, written to test the [increment contract](https://github.com/stellar/soroban-examples/blob/main/increment/src/lib.rs). The contract has an `increment` function, that increases a counter value by one on every invocation. The following test invokes that contract's function several times, and checks that the value increases by one.
1313

1414
```rust
1515
#![cfg(test)]
@@ -71,4 +71,11 @@ The `Env` created at the beginning of the test is not a simulation of the Soroba
7171

7272
:::
7373

74-
[increment contract]: https://github.com/stellar/soroban-examples/blob/main/increment/src/lib.rs
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.

docs/tokens/publishing-asset-info.mdx

Lines changed: 48 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -133,28 +133,27 @@ You should also use the `set_options` operation to set the home domain on your i
133133

134134
```nginx title="Configure stellar.toml for nginx"
135135
server {
136-
137-
server_name my.example.com;
138-
root /var/www/my.example.com;
139-
140-
location = /.well-known/stellar.toml {
141-
types { } default_type "text/plain; charset=utf-8";
142-
allow all;
143-
if ($request_method = 'OPTIONS') {
144-
add_header 'Access-Control-Allow-Origin' '*';
145-
add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
146-
add_header 'Content-Length' 0;
147-
return 204;
148-
}
149-
if ($request_method = 'GET') {
150-
add_header 'Access-Control-Allow-Origin' '*';
151-
add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
152-
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
153-
}
154-
}
155-
156-
// CertBot SSL configuration
157-
// ...
136+
server_name my.example.com;
137+
root /var/www/my.example.com;
138+
139+
location = /.well-known/stellar.toml {
140+
types { } default_type "text/plain; charset=utf-8";
141+
allow all;
142+
if ($request_method = 'OPTIONS') {
143+
add_header 'Access-Control-Allow-Origin' '*';
144+
add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
145+
add_header 'Content-Length' 0;
146+
return 204;
147+
}
148+
if ($request_method = 'GET') {
149+
add_header 'Access-Control-Allow-Origin' '*';
150+
add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
151+
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
152+
}
153+
}
154+
155+
// CertBot SSL configuration
156+
// ...
158157
}
159158
```
160159

@@ -208,33 +207,31 @@ server = Server(horizon_url="https://horizon-testnet.stellar.org")
208207
network_passphrase = Network.TESTNET_NETWORK_PASSPHRASE
209208

210209
# Keys for accounts to issue and receive the new asset
211-
issuing_keypair = Keypair.from_secret(
212-
"SCZANGBA5YHTNYVVV4C3U252E2B6P6F5T3U6MM63WBSBZATAQI3EBTQ4"
213-
)
210+
issuing_keypair = Keypair.from_secret("SCZANGBA5YHTNYVVV4C3U252E2B6P6F5T3U6MM63WBSBZATAQI3EBTQ4")
214211
issuing_public = issuing_keypair.public_key
215212

216-
217213
# Transactions require a valid sequence number that is specific to this account.
218214
# We can fetch the current sequence number for the source account from Horizon.
219215
issuing_account = server.load_account(issuing_public)
220216

221217
transaction = (
222-
TransactionBuilder(
223-
source_account=issuing_account,
224-
network_passphrase=network_passphrase,
225-
base_fee=100,
226-
)
227-
.append_set_options_op(
228-
home_domain="yourdomain.com"
229-
)
230-
.build()
218+
TransactionBuilder(
219+
source_account = issuing_account,
220+
network_passphrase = network_passphrase,
221+
base_fee = 100,
222+
)
223+
.append_set_options_op(
224+
home_domain = "yourdomain.com"
225+
)
226+
.build()
231227
)
232228
transaction.sign(issuing_keypair)
229+
233230
try:
234-
transaction_resp = server.submit_transaction(transaction)
235-
print(f"Transaction Resp:\n{transaction_resp}")
231+
transaction_resp = server.submit_transaction(transaction)
232+
print(f"Transaction Resp:\n{transaction_resp}")
236233
except BaseHorizonError as e:
237-
print(f"Error: {e}")
234+
print(f"Error: {e}")
238235
```
239236

240237
```java
@@ -265,19 +262,19 @@ func main() {
265262
}
266263

267264
// Build the transaction
268-
tx, err := txnbuild.NewTransaction(
269-
txnbuild.TransactionParams{
270-
SourceAccount: &issuingAccount,
271-
IncrementSequenceNum: true,
272-
BaseFee: txnbuild.MinBaseFee,
273-
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimeout(100)},
274-
Operations: []txnbuild.Operation{
275-
&txnbuild.SetOptions{
276-
HomeDomain: "yourdomain.com",
277-
},
278-
},
279-
},
280-
)
265+
tx, err := txnbuild.NewTransaction(
266+
txnbuild.TransactionParams{
267+
SourceAccount: &issuingAccount,
268+
IncrementSequenceNum: true,
269+
BaseFee: txnbuild.MinBaseFee,
270+
Preconditions: txnbuild.Preconditions{TimeBounds: txnbuild.NewTimeout(100)},
271+
Operations: []txnbuild.Operation{
272+
&txnbuild.SetOptions{
273+
HomeDomain: "yourdomain.com",
274+
},
275+
},
276+
},
277+
)
281278
if err != nil {
282279
log.Fatal(err)
283280
}

0 commit comments

Comments
 (0)