Skip to content

Commit

Permalink
Fixed "h instead of b in hex literal syntax" libra breaking change (s…
Browse files Browse the repository at this point in the history
…ee: diem/diem@009bc2d#diff-012956fdf7725fc352139c08a571ec30).

readme file update (added running the code instruction section).
  • Loading branch information
Alon Shavit committed Aug 3, 2019
1 parent 2d2e9a4 commit 63a3ee2
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,46 @@ The atomic swap is being done in the following way:

For the sake of simplicity we ignore the case where Alice does not reveal her secret, or the case where Bob does not deploy his contract. However these cases can be easily handled by putting a time lock in the contract that will allow the deployer to withdraw his or her assets in case the counter party acted maliciously.

## Running the project
To run the atomic_swap implementation test, you should perform the following steps:

- Clone the Libra Core Repository:

```
git clone https://github.com/libra/libra.git
```

Change to the libra directory:

```
cd libra
```

Setup Libra Core:

To setup Libra Core, run the setup script to install the dependencies
```
./scripts/dev_setup.sh
```

The setup script performs these actions:

Installs rustup — rustup is an installer for the Rust programming language, which Libra Core is implemented in.
It Installs the required versions of the rust-toolchain.
Installs CMake — to manage the build process.
Installs protoc — a compiler for protocol buffers.
Also, installs Go — for building protocol buffers.

Copy the atomic_swap.mvir (Move IR source code) to the test folder in the Libra repository located at language/functional_tests/tests/testsuite/modules


Execute the following command in the Libra repository:

```
cargo test -p functional_tests atomic_swap
```

Note: If your tests failed, edit the `atomic_swap.mvir` file and run the following command to rerun the tests:

cargo test -p functional_tests --test testsuite

4 changes: 2 additions & 2 deletions atomic_swap.mvir
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ main() {

sender = get_txn_sender();

secret = b"abcd";
result = b"dbe576b4818846aa77e82f4ed5fa78f92766b141f282d36703886d196df39322";
secret = h"abcd";
result = h"dbe576b4818846aa77e82f4ed5fa78f92766b141f282d36703886d196df39322";

recipient_address = 0xb0b;
coin = LibraAccount.withdraw_from_sender(1000);
Expand Down

0 comments on commit 63a3ee2

Please sign in to comment.