mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-12-25 07:29:32 -05:00
Merge branch 'master' into bugfix/asb-sync-startup
This commit is contained in:
commit
8280389495
8
.github/workflows/build-release-binaries.yml
vendored
8
.github/workflows/build-release-binaries.yml
vendored
@ -45,16 +45,16 @@ jobs:
|
|||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout tagged commit
|
- name: Checkout tagged commit
|
||||||
uses: actions/checkout@v4.0.0
|
uses: actions/checkout@v4.1.1
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.event.release.target_commitish }}
|
ref: ${{ github.event.release.target_commitish }}
|
||||||
token: ${{ secrets.BOTTY_GITHUB_TOKEN }}
|
token: ${{ secrets.BOTTY_GITHUB_TOKEN }}
|
||||||
|
|
||||||
- uses: Swatinem/rust-cache@v2.6.2
|
- uses: Swatinem/rust-cache@v2.7.1
|
||||||
|
|
||||||
- uses: dtolnay/rust-toolchain@master
|
- uses: dtolnay/rust-toolchain@master
|
||||||
with:
|
with:
|
||||||
toolchain: 1.67
|
toolchain: "1.70"
|
||||||
targets: armv7-unknown-linux-gnueabihf
|
targets: armv7-unknown-linux-gnueabihf
|
||||||
|
|
||||||
- name: Build ${{ matrix.target }} ${{ matrix.bin }} release binary
|
- name: Build ${{ matrix.target }} ${{ matrix.bin }} release binary
|
||||||
@ -69,7 +69,7 @@ jobs:
|
|||||||
run: target/${{ matrix.target }}/release/${{ matrix.bin }} --help
|
run: target/${{ matrix.target }}/release/${{ matrix.bin }} --help
|
||||||
|
|
||||||
# Remove once python 3 is the default
|
# Remove once python 3 is the default
|
||||||
- uses: actions/setup-python@v4
|
- uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: "3.x"
|
python-version: "3.x"
|
||||||
|
|
||||||
|
34
.github/workflows/ci.yml
vendored
34
.github/workflows/ci.yml
vendored
@ -4,8 +4,6 @@ on:
|
|||||||
pull_request: # Need to run on pull-requests, otherwise PRs from forks don't run
|
pull_request: # Need to run on pull-requests, otherwise PRs from forks don't run
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- "staging" # Bors uses this branch
|
|
||||||
- "trying" # Bors uses this branch
|
|
||||||
- "master" # Always build head of master for the badge in the README
|
- "master" # Always build head of master for the badge in the README
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@ -13,14 +11,14 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v4.0.0
|
uses: actions/checkout@v4.1.1
|
||||||
|
|
||||||
- uses: dtolnay/rust-toolchain@master
|
- uses: dtolnay/rust-toolchain@master
|
||||||
with:
|
with:
|
||||||
toolchain: 1.67
|
toolchain: "1.70"
|
||||||
components: clippy,rustfmt
|
components: clippy,rustfmt
|
||||||
|
|
||||||
- uses: Swatinem/rust-cache@v2.6.2
|
- uses: Swatinem/rust-cache@v2.7.1
|
||||||
|
|
||||||
- name: Check formatting
|
- name: Check formatting
|
||||||
uses: dprint/check@v2.2
|
uses: dprint/check@v2.2
|
||||||
@ -37,9 +35,9 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v4.0.0
|
uses: actions/checkout@v4.1.1
|
||||||
|
|
||||||
- uses: Swatinem/rust-cache@v2.6.2
|
- uses: Swatinem/rust-cache@v2.7.1
|
||||||
|
|
||||||
- name: Build swap
|
- name: Build swap
|
||||||
run: cargo build --bin swap
|
run: cargo build --bin swap
|
||||||
@ -51,9 +49,9 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v4.0.0
|
uses: actions/checkout@v4.1.1
|
||||||
|
|
||||||
- uses: Swatinem/rust-cache@v2.6.2
|
- uses: Swatinem/rust-cache@v2.7.1
|
||||||
|
|
||||||
- name: Install sqlx-cli
|
- name: Install sqlx-cli
|
||||||
run: cargo install sqlx-cli --locked
|
run: cargo install sqlx-cli --locked
|
||||||
@ -78,13 +76,13 @@ jobs:
|
|||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v4.0.0
|
uses: actions/checkout@v4.1.1
|
||||||
|
|
||||||
- uses: Swatinem/rust-cache@v2.6.2
|
- uses: Swatinem/rust-cache@v2.7.1
|
||||||
|
|
||||||
- uses: dtolnay/rust-toolchain@master
|
- uses: dtolnay/rust-toolchain@master
|
||||||
with:
|
with:
|
||||||
toolchain: 1.67
|
toolchain: "1.70"
|
||||||
targets: armv7-unknown-linux-gnueabihf
|
targets: armv7-unknown-linux-gnueabihf
|
||||||
|
|
||||||
- name: Build binary
|
- name: Build binary
|
||||||
@ -100,13 +98,13 @@ jobs:
|
|||||||
run: cross build -p swap --target ${{ matrix.target }}
|
run: cross build -p swap --target ${{ matrix.target }}
|
||||||
|
|
||||||
- name: Upload swap binary
|
- name: Upload swap binary
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: swap-${{ matrix.target }}
|
name: swap-${{ matrix.target }}
|
||||||
path: target/${{ matrix.target }}/debug/swap
|
path: target/${{ matrix.target }}/debug/swap
|
||||||
|
|
||||||
- name: Upload asb binary
|
- name: Upload asb binary
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: asb-${{ matrix.target }}
|
name: asb-${{ matrix.target }}
|
||||||
path: target/${{ matrix.target }}/debug/asb
|
path: target/${{ matrix.target }}/debug/asb
|
||||||
@ -118,9 +116,9 @@ jobs:
|
|||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v4.0.0
|
uses: actions/checkout@v4.1.1
|
||||||
|
|
||||||
- uses: Swatinem/rust-cache@v2.6.2
|
- uses: Swatinem/rust-cache@v2.7.1
|
||||||
|
|
||||||
- name: Build tests
|
- name: Build tests
|
||||||
run: cargo build --tests --workspace --all-features
|
run: cargo build --tests --workspace --all-features
|
||||||
@ -155,9 +153,9 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
uses: actions/checkout@v4.0.0
|
uses: actions/checkout@v4.1.1
|
||||||
|
|
||||||
- uses: Swatinem/rust-cache@v2.6.2
|
- uses: Swatinem/rust-cache@v2.7.1
|
||||||
|
|
||||||
- name: Run test ${{ matrix.test_name }}
|
- name: Run test ${{ matrix.test_name }}
|
||||||
run: cargo test --package swap --all-features --test ${{ matrix.test_name }} -- --nocapture
|
run: cargo test --package swap --all-features --test ${{ matrix.test_name }} -- --nocapture
|
||||||
|
2
.github/workflows/create-release.yml
vendored
2
.github/workflows/create-release.yml
vendored
@ -11,7 +11,7 @@ jobs:
|
|||||||
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/')
|
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/')
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4.0.0
|
- uses: actions/checkout@v4.1.1
|
||||||
|
|
||||||
- name: Extract version from branch name
|
- name: Extract version from branch name
|
||||||
id: extract-version
|
id: extract-version
|
||||||
|
4
.github/workflows/draft-new-release.yml
vendored
4
.github/workflows/draft-new-release.yml
vendored
@ -12,7 +12,7 @@ jobs:
|
|||||||
name: "Draft a new release"
|
name: "Draft a new release"
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4.0.0
|
- uses: actions/checkout@v4.1.1
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.BOTTY_GITHUB_TOKEN }}
|
token: ${{ secrets.BOTTY_GITHUB_TOKEN }}
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ jobs:
|
|||||||
id: make-commit
|
id: make-commit
|
||||||
env:
|
env:
|
||||||
DPRINT_VERSION: 0.39.1
|
DPRINT_VERSION: 0.39.1
|
||||||
RUST_TOOLCHAIN: 1.67
|
RUST_TOOLCHAIN: 1.70
|
||||||
run: |
|
run: |
|
||||||
rustup component add rustfmt --toolchain "$RUST_TOOLCHAIN-x86_64-unknown-linux-gnu"
|
rustup component add rustfmt --toolchain "$RUST_TOOLCHAIN-x86_64-unknown-linux-gnu"
|
||||||
curl -fsSL https://dprint.dev/install.sh | sh -s $DPRINT_VERSION
|
curl -fsSL https://dprint.dev/install.sh | sh -s $DPRINT_VERSION
|
||||||
|
2
.github/workflows/preview-release.yml
vendored
2
.github/workflows/preview-release.yml
vendored
@ -10,7 +10,7 @@ jobs:
|
|||||||
name: Create preview release
|
name: Create preview release
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4.0.0
|
- uses: actions/checkout@v4.1.1
|
||||||
|
|
||||||
- name: Delete 'preview' release
|
- name: Delete 'preview' release
|
||||||
uses: larryjoelane/delete-release-action@v1.0.24
|
uses: larryjoelane/delete-release-action@v1.0.24
|
||||||
|
@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
- Minimum Supported Rust Version (MSRV) bumped to 1.70
|
||||||
|
|
||||||
## [0.12.3] - 2023-09-20
|
## [0.12.3] - 2023-09-20
|
||||||
|
|
||||||
- Swap: If no Monero daemon is manually specified, we will automatically choose one from a list of public daemons by connecting to each and checking their availability.
|
- Swap: If no Monero daemon is manually specified, we will automatically choose one from a list of public daemons by connecting to each and checking their availability.
|
||||||
|
776
Cargo.lock
generated
776
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -50,7 +50,7 @@ Please have a look at the [contribution guidelines](./CONTRIBUTING.md).
|
|||||||
## Rust Version Support
|
## Rust Version Support
|
||||||
|
|
||||||
Please note that only the latest stable Rust toolchain is supported.
|
Please note that only the latest stable Rust toolchain is supported.
|
||||||
All stable toolchains since 1.67 _should_ work.
|
All stable toolchains since 1.70 _should_ work.
|
||||||
|
|
||||||
## Contact
|
## Contact
|
||||||
|
|
||||||
|
25
bors.toml
25
bors.toml
@ -1,25 +0,0 @@
|
|||||||
status = [
|
|
||||||
"static_analysis",
|
|
||||||
"bdk_test",
|
|
||||||
"sqlx_test",
|
|
||||||
"build (x86_64-unknown-linux-gnu, ubuntu-latest)",
|
|
||||||
"build (armv7-unknown-linux-gnueabihf, ubuntu-latest)",
|
|
||||||
"build (x86_64-apple-darwin, macos-latest)",
|
|
||||||
"build (x86_64-pc-windows-msvc, windows-latest)",
|
|
||||||
"test (ubuntu-latest)",
|
|
||||||
"test (macos-latest)",
|
|
||||||
"docker_tests (happy_path)",
|
|
||||||
"docker_tests (happy_path_restart_bob_after_xmr_locked)",
|
|
||||||
"docker_tests (happy_path_restart_alice_after_xmr_locked)",
|
|
||||||
"docker_tests (happy_path_restart_bob_before_xmr_locked)",
|
|
||||||
"docker_tests (alice_and_bob_refund_using_cancel_and_refund_command)",
|
|
||||||
"docker_tests (alice_and_bob_refund_using_cancel_then_refund_command)",
|
|
||||||
"docker_tests (alice_and_bob_refund_using_cancel_and_refund_command_timelock_not_expired)",
|
|
||||||
"docker_tests (punish)",
|
|
||||||
"docker_tests (alice_punishes_after_restart_bob_dead)",
|
|
||||||
"docker_tests (alice_manually_punishes_after_bob_dead)",
|
|
||||||
"docker_tests (alice_refunds_after_restart_bob_refunded)",
|
|
||||||
"docker_tests (ensure_same_swap_id)",
|
|
||||||
"docker_tests (concurrent_bobs_before_xmr_lock_proof_sent)",
|
|
||||||
"docker_tests (alice_manually_redeems_after_enc_sig_learned)"
|
|
||||||
]
|
|
@ -1,4 +1,4 @@
|
|||||||
[toolchain]
|
[toolchain]
|
||||||
channel = "1.67" # also update this in the readme, changelog, and github actions
|
channel = "1.70" # also update this in the readme, changelog, and github actions
|
||||||
components = ["clippy"]
|
components = ["clippy"]
|
||||||
targets = ["armv7-unknown-linux-gnueabihf"]
|
targets = ["armv7-unknown-linux-gnueabihf"]
|
||||||
|
@ -19,11 +19,11 @@ bdk = "0.28"
|
|||||||
big-bytes = "1"
|
big-bytes = "1"
|
||||||
bitcoin = { version = "0.29", features = [ "rand", "serde" ] }
|
bitcoin = { version = "0.29", features = [ "rand", "serde" ] }
|
||||||
bmrng = "0.5"
|
bmrng = "0.5"
|
||||||
comfy-table = "6.1"
|
comfy-table = "7.1"
|
||||||
config = { version = "0.13", default-features = false, features = [ "toml" ] }
|
config = { version = "0.13", default-features = false, features = [ "toml" ] }
|
||||||
conquer-once = "0.4"
|
conquer-once = "0.4"
|
||||||
curve25519-dalek = { package = "curve25519-dalek-ng", version = "4" }
|
curve25519-dalek = { package = "curve25519-dalek-ng", version = "4" }
|
||||||
data-encoding = "2.4"
|
data-encoding = "2.5"
|
||||||
dialoguer = "0.10"
|
dialoguer = "0.10"
|
||||||
directories-next = "2"
|
directories-next = "2"
|
||||||
ecdsa_fun = { git = "https://github.com/LLFourn/secp256kfun", default-features = false, features = [ "libsecp_compat", "serde", "adaptor" ] }
|
ecdsa_fun = { git = "https://github.com/LLFourn/secp256kfun", default-features = false, features = [ "libsecp_compat", "serde", "adaptor" ] }
|
||||||
@ -34,9 +34,9 @@ itertools = "0.10"
|
|||||||
libp2p = { version = "0.42.2", default-features = false, features = [ "tcp-tokio", "yamux", "mplex", "dns-tokio", "noise", "request-response", "websocket", "ping", "rendezvous", "identify" ] }
|
libp2p = { version = "0.42.2", default-features = false, features = [ "tcp-tokio", "yamux", "mplex", "dns-tokio", "noise", "request-response", "websocket", "ping", "rendezvous", "identify" ] }
|
||||||
monero = { version = "0.12", features = [ "serde_support" ] }
|
monero = { version = "0.12", features = [ "serde_support" ] }
|
||||||
monero-rpc = { path = "../monero-rpc" }
|
monero-rpc = { path = "../monero-rpc" }
|
||||||
pem = "1.1"
|
pem = "3.0"
|
||||||
proptest = "1"
|
proptest = "1"
|
||||||
qrcode = "0.12"
|
qrcode = "0.13"
|
||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
rand_chacha = "0.3"
|
rand_chacha = "0.3"
|
||||||
reqwest = { version = "0.11", features = [ "rustls-tls", "stream", "socks" ], default-features = false }
|
reqwest = { version = "0.11", features = [ "rustls-tls", "stream", "socks" ], default-features = false }
|
||||||
@ -50,21 +50,21 @@ sha2 = "0.10"
|
|||||||
sigma_fun = { git = "https://github.com/LLFourn/secp256kfun", default-features = false, features = [ "ed25519", "serde", "secp256k1", "alloc" ] }
|
sigma_fun = { git = "https://github.com/LLFourn/secp256kfun", default-features = false, features = [ "ed25519", "serde", "secp256k1", "alloc" ] }
|
||||||
sqlx = { version = "0.6", features = [ "sqlite", "runtime-tokio-rustls", "offline" ] }
|
sqlx = { version = "0.6", features = [ "sqlite", "runtime-tokio-rustls", "offline" ] }
|
||||||
structopt = "0.3"
|
structopt = "0.3"
|
||||||
strum = { version = "0.24", features = [ "derive" ] }
|
strum = { version = "0.25", features = [ "derive" ] }
|
||||||
thiserror = "1"
|
thiserror = "1"
|
||||||
time = "0.3"
|
time = "0.3"
|
||||||
tokio = { version = "1", features = [ "rt-multi-thread", "time", "macros", "sync", "process", "fs", "net" ] }
|
tokio = { version = "1", features = [ "rt-multi-thread", "time", "macros", "sync", "process", "fs", "net" ] }
|
||||||
tokio-socks = "0.5"
|
tokio-socks = "0.5"
|
||||||
tokio-tungstenite = { version = "0.15", features = [ "rustls-tls" ] }
|
tokio-tungstenite = { version = "0.15", features = [ "rustls-tls" ] }
|
||||||
tokio-util = { version = "0.7", features = [ "io", "codec" ] }
|
tokio-util = { version = "0.7", features = [ "io", "codec" ] }
|
||||||
toml = "0.5"
|
toml = "0.7"
|
||||||
torut = { version = "0.2", default-features = false, features = [ "v3", "control" ] }
|
torut = { version = "0.2", default-features = false, features = [ "v3", "control" ] }
|
||||||
tracing = { version = "0.1", features = [ "attributes" ] }
|
tracing = { version = "0.1", features = [ "attributes" ] }
|
||||||
tracing-appender = "0.2"
|
tracing-appender = "0.2"
|
||||||
tracing-futures = { version = "0.2", features = [ "std-future", "futures-03" ] }
|
tracing-futures = { version = "0.2", features = [ "std-future", "futures-03" ] }
|
||||||
tracing-subscriber = { version = "0.3", default-features = false, features = [ "fmt", "ansi", "env-filter", "time", "tracing-log", "json" ] }
|
tracing-subscriber = { version = "0.3", default-features = false, features = [ "fmt", "ansi", "env-filter", "time", "tracing-log", "json" ] }
|
||||||
url = { version = "2", features = [ "serde" ] }
|
url = { version = "2", features = [ "serde" ] }
|
||||||
uuid = { version = "1.4", features = [ "serde", "v4" ] }
|
uuid = { version = "1.6", features = [ "serde", "v4" ] }
|
||||||
void = "1"
|
void = "1"
|
||||||
|
|
||||||
[target.'cfg(not(windows))'.dependencies]
|
[target.'cfg(not(windows))'.dependencies]
|
||||||
@ -76,8 +76,8 @@ zip = "0.5"
|
|||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
bitcoin-harness = "0.2.2"
|
bitcoin-harness = "0.2.2"
|
||||||
get-port = "3"
|
get-port = "3"
|
||||||
hyper = "0.14"
|
hyper = "1.0"
|
||||||
mockito = "1.1.0"
|
mockito = "1.2.0"
|
||||||
monero-harness = { path = "../monero-harness" }
|
monero-harness = { path = "../monero-harness" }
|
||||||
port_check = "0.1"
|
port_check = "0.1"
|
||||||
proptest = "1"
|
proptest = "1"
|
||||||
|
@ -46,7 +46,7 @@ pub struct Regtest;
|
|||||||
impl GetConfig for Mainnet {
|
impl GetConfig for Mainnet {
|
||||||
fn get_config() -> Config {
|
fn get_config() -> Config {
|
||||||
Config {
|
Config {
|
||||||
bitcoin_lock_mempool_timeout: 3.std_minutes(),
|
bitcoin_lock_mempool_timeout: 10.std_minutes(),
|
||||||
bitcoin_lock_confirmed_timeout: 2.std_hours(),
|
bitcoin_lock_confirmed_timeout: 2.std_hours(),
|
||||||
bitcoin_finality_confirmations: 1,
|
bitcoin_finality_confirmations: 1,
|
||||||
bitcoin_avg_block_time: 10.std_minutes(),
|
bitcoin_avg_block_time: 10.std_minutes(),
|
||||||
@ -63,7 +63,7 @@ impl GetConfig for Mainnet {
|
|||||||
impl GetConfig for Testnet {
|
impl GetConfig for Testnet {
|
||||||
fn get_config() -> Config {
|
fn get_config() -> Config {
|
||||||
Config {
|
Config {
|
||||||
bitcoin_lock_mempool_timeout: 3.std_minutes(),
|
bitcoin_lock_mempool_timeout: 10.std_minutes(),
|
||||||
bitcoin_lock_confirmed_timeout: 1.std_hours(),
|
bitcoin_lock_confirmed_timeout: 1.std_hours(),
|
||||||
bitcoin_finality_confirmations: 1,
|
bitcoin_finality_confirmations: 1,
|
||||||
bitcoin_avg_block_time: 10.std_minutes(),
|
bitcoin_avg_block_time: 10.std_minutes(),
|
||||||
|
@ -106,11 +106,12 @@ impl Seed {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn from_pem(pem: pem::Pem) -> Result<Self, Error> {
|
fn from_pem(pem: pem::Pem) -> Result<Self, Error> {
|
||||||
if pem.contents.len() != SEED_LENGTH {
|
let contents = pem.contents();
|
||||||
Err(Error::IncorrectLength(pem.contents.len()))
|
if contents.len() != SEED_LENGTH {
|
||||||
|
Err(Error::IncorrectLength(contents.len()))
|
||||||
} else {
|
} else {
|
||||||
let mut array = [0; SEED_LENGTH];
|
let mut array = [0; SEED_LENGTH];
|
||||||
for (i, b) in pem.contents.iter().enumerate() {
|
for (i, b) in contents.iter().enumerate() {
|
||||||
array[i] = *b;
|
array[i] = *b;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,10 +123,7 @@ impl Seed {
|
|||||||
ensure_directory_exists(&seed_file)?;
|
ensure_directory_exists(&seed_file)?;
|
||||||
|
|
||||||
let data = self.bytes();
|
let data = self.bytes();
|
||||||
let pem = Pem {
|
let pem = Pem::new("SEED", data);
|
||||||
tag: String::from("SEED"),
|
|
||||||
contents: data.to_vec(),
|
|
||||||
};
|
|
||||||
|
|
||||||
let pem_string = encode(&pem);
|
let pem_string = encode(&pem);
|
||||||
|
|
||||||
@ -224,19 +222,20 @@ VnZUNFZ4dlY=
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic]
|
|
||||||
fn seed_from_pem_fails_for_long_seed() {
|
fn seed_from_pem_fails_for_long_seed() {
|
||||||
let long = "-----BEGIN SEED-----
|
let long = "-----BEGIN SEED-----
|
||||||
mbKANv2qKGmNVg1qtquj6Hx1pFPelpqOfE2JaJJAMEg1FlFhNRNlFlE=
|
MIIBPQIBAAJBAOsfi5AGYhdRs/x6q5H7kScxA0Kzzqe6WI6gf6+tc6IvKQJo5rQc
|
||||||
mbKANv2qKGmNVg1qtquj6Hx1pFPelpqOfE2JaJJAMEg1FlFhNRNlFlE=
|
dWWSQ0nRGt2hOPDO+35NKhQEjBQxPh/v7n0CAwEAAQJBAOGaBAyuw0ICyENy5NsO
|
||||||
-----END SEED-----
|
-----END SEED-----
|
||||||
";
|
";
|
||||||
let pem = pem::parse(long).unwrap();
|
let pem = pem::parse(long).unwrap();
|
||||||
|
assert_eq!(pem.contents().len(), 96);
|
||||||
|
|
||||||
match Seed::from_pem(pem) {
|
match Seed::from_pem(pem) {
|
||||||
Ok(_) => panic!("should fail for long payload"),
|
Ok(_) => panic!("should fail for long payload"),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
match e {
|
match e {
|
||||||
Error::IncorrectLength(_) => {} // pass
|
Error::IncorrectLength(len) => assert_eq!(len, 96), // pass
|
||||||
_ => panic!("should fail with IncorrectLength error"),
|
_ => panic!("should fail with IncorrectLength error"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user