Skip to content

Commit

Permalink
Update how-to-test-a-contract.md
Browse files Browse the repository at this point in the history
Move shallow copy section.
  • Loading branch information
msinkec authored Feb 6, 2024
1 parent e74f8c1 commit d23f292
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions docs/how-to-test-a-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,19 +155,6 @@ describe('Test SmartContract `Demo`', () => {
})
```

## Shallow Copy

Sometimes, if you only want to do a shallow copy of some properties, you can pass in the property names as an optional argument like this:

```ts
const nextInstance = instance.next(
{
refCloneProps: ['prop1', 'prop2']
}
)
```
In this context the `next` is designed to create a shallow copy of the specified properties, allowing for selective copy rather than a complete copy of the entire contract instance.

## Run tests


Expand Down Expand Up @@ -271,6 +258,19 @@ nextInstance.increment();
```
This is the **SAME** method we call on chain in `incrementOnChain`, thanks to the fact that both the on-chain smart contract and off-chain code are written in TypeScript.

#### Shallow Copy

Sometimes, if you only want to do a shallow copy of some properties, you can pass in the property names as an optional argument like this:

```ts
const nextInstance = instance.next(
{
refCloneProps: ['prop1', 'prop2']
}
)
```
In this context the `next` is designed to create a shallow copy of the specified properties, allowing for selective copy rather than a complete copy of the entire contract instance.

### 3. Call the method on the `current` instance to apply updates on chain

As described in [this section](#call-a-public-method), we can build a call transaction. The only difference here is that we pass in the `next` instance and its balance as a method call option in a stateful contract. So the method (i.e., `incrementOnChain`) have all the information to verify that all updates made to the `next` instance follow the state transition rules in it.
Expand Down

0 comments on commit d23f292

Please sign in to comment.