Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tapret_wlt_receiving_opret 100 times #16

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 5 additions & 49 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,61 +10,17 @@ env:
CARGO_TERM_COLOR: always

jobs:
lint:
test_tapret_wlt_receiving_opret:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: clippy
- name: Lint
run: cargo clippy --all-targets -- -D warnings

format:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: rustfmt
- name: Format
run: cargo fmt --all -- --check

test_and_coverage:
runs-on: ubuntu-latest

timeout-minutes: 100
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true

- name: Setup rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: llvm-tools-preview
toolchain: stable

- name: Install llvm-cov
env:
LLVM_COV_RELEASES: https://github.com/taiki-e/cargo-llvm-cov/releases
- name: Run tapret_wlt_receiving_opret test 100 times
run: |
host=$(rustc -Vv | grep host | sed 's/host: //')
curl -fsSL $LLVM_COV_RELEASES/latest/download/cargo-llvm-cov-$host.tar.gz | tar xzf - -C "$HOME/.cargo/bin"

- name: Test and generate coverage report
run: |
INDEXER=esplora cargo llvm-cov --output-path coverage.lcov
INDEXER=electrum cargo llvm-cov --no-clean --output-path coverage.lcov

- name: Upload coverage report
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
file: coverage.lcov
flags: rust
token: ${{ secrets.CODECOV_TOKEN }}
cargo test --test transfers tapret_wlt_receiving_opret
for i in $(seq 1 100); do echo "run $i"; SKIP_INIT=1 cargo test --test transfers tapret_wlt_receiving_opret || break; done
37 changes: 33 additions & 4 deletions tests/transfers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,6 @@ fn mainnet_wlt_receiving_test_asset() {
}

#[test]
#[ignore = "this was working, fix needed"]
fn tapret_wlt_receiving_opret() {
initialize();

Expand All @@ -746,7 +745,7 @@ fn tapret_wlt_receiving_opret() {
let (contract_id, iface_type_name) = wlt_1.issue_nia(600, wlt_1.close_method(), None);

println!("1st transfer");
wlt_1.send(
let (consignment, _) = wlt_1.send(
&mut wlt_2,
TransferType::Blinded,
contract_id,
Expand All @@ -755,6 +754,8 @@ fn tapret_wlt_receiving_opret() {
5000,
None,
);
assert_eq!(consignment.bundles.len(), 1);
assert_eq!(consignment.terminals.len(), 1);

println!("2nd transfer");
let invoice = wlt_1.invoice(
Expand All @@ -764,10 +765,12 @@ fn tapret_wlt_receiving_opret() {
CloseMethod::OpretFirst,
InvoiceType::Witness,
);
wlt_2.send_to_invoice(&mut wlt_1, invoice, None, None, None);
let (consignment, _) = wlt_2.send_to_invoice(&mut wlt_1, invoice, None, None, None);
assert_eq!(consignment.bundles.len(), 2);
assert_eq!(consignment.terminals.len(), 0);

println!("3rd transfer");
wlt_1.send(
let (consignment, _) = wlt_1.send(
&mut wlt_2,
TransferType::Blinded,
contract_id,
Expand All @@ -776,4 +779,30 @@ fn tapret_wlt_receiving_opret() {
1000,
None,
);
assert_eq!(consignment.bundles.len(), 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But this must be 3, isn't it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, 0 is incorrect. The "fixing" PR has introduced this bug, as explained in #6 (comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is a bug I believe it must be a failing assertion, so we do not merge this PR unless the bug is fixed

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the message of this PR, it says:

This is not meant to be merged, it's just here to push ahead the discussion in #6

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I see that, but what confuses me is that all other PRs here fail unless there is a fix - and this one follows different approach

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose of this PR is showing the tests are deterministic and there is no such case of consignment changing the number of bundles based on a run executed on a different hour/day. If I change the assertion the test would fail and it wouldn't be possible to show that it deterministically returns 0 bundles at every run. I don't see any issue in having a PR with a different approach since there are no better alternatives. Do you see alternatives?

assert_eq!(consignment.terminals.len(), 0);

/*
println!("4th transfer");
wlt_2.send(
&mut wlt_1,
TransferType::Blinded,
contract_id,
&iface_type_name,
560,
1000,
None,
);

println!("5th transfer");
wlt_1.send(
&mut wlt_2,
TransferType::Blinded,
contract_id,
&iface_type_name,
600,
1000,
None,
);
*/
}