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

refactor!: use typestate for receivedreceipt #196

Merged
merged 5 commits into from
Dec 22, 2023

Conversation

gusinacio
Copy link
Contributor

@gusinacio gusinacio commented Dec 19, 2023

New state machine

  • Using typestate pattern for ReceivedReceipt state machine
  • States are now enforced by compile time and don't need to be checked by tests
  • Transitions consume the old value creating a new state
graph TD;
    Checking-->AwaitingReserve;
    AwaitingReserve-->Reserved;
    Checking-->Failed;
    AwaitingReserve-->Failed;
Loading

Remove RAV status

  • The manager was not using rav statuses
  • Implementation in tap-agent was not using it
  • Removed from tests

Escrow check is now a state

  • Escrow check was a special optional check (a ReceivedReceipt may or may not have the required check)
  • Escrow reserve is now a mandatory state
  • Must be executed after all checks have passed

@gusinacio gusinacio force-pushed the gusinacio/state-machine-refactor branch from 0b4a1c7 to 43d615d Compare December 19, 2023 00:33

This comment has been minimized.

@gusinacio gusinacio force-pushed the gusinacio/state-machine-refactor branch from 43d615d to 8be0c51 Compare December 19, 2023 00:34

This comment has been minimized.

1 similar comment

This comment has been minimized.

Copy link

github-actions bot commented Dec 19, 2023

Pull Request Test Coverage Report for Build 7302659958

  • 205 of 260 (78.85%) changed or added relevant lines in 6 files are covered.
  • 84 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-7.0%) to 75.586%

Changes Missing Coverage Covered Lines Changed/Added Lines %
tap_core/src/adapters/mock/receipt_storage_adapter_mock.rs 6 7 85.71%
tap_core/src/tap_manager/manager.rs 46 49 93.88%
tap_core/src/tap_receipt/receipt_auditor.rs 3 23 13.04%
tap_core/src/tap_receipt/received_receipt.rs 138 169 81.66%
Files with Coverage Reduction New Missed Lines %
tap_core/src/tap_receipt/received_receipt.rs 12 80.91%
tap_core/src/tap_receipt/receipt_auditor.rs 72 53.78%
Totals Coverage Status
Change from base Build 7256326493: -7.0%
Covered Lines: 1161
Relevant Lines: 1536

💛 - Coveralls

@gusinacio gusinacio force-pushed the gusinacio/state-machine-refactor branch from 8be0c51 to ef4e62d Compare December 19, 2023 00:47

This comment has been minimized.

@gusinacio gusinacio force-pushed the gusinacio/state-machine-refactor branch 2 times, most recently from 4189a22 to 3d7d588 Compare December 19, 2023 01:01

This comment has been minimized.

1 similar comment

This comment has been minimized.

@gusinacio gusinacio force-pushed the gusinacio/state-machine-refactor branch from 3d7d588 to 5be9063 Compare December 19, 2023 01:11

This comment has been minimized.

@gusinacio gusinacio force-pushed the gusinacio/state-machine-refactor branch from 5be9063 to 1dcfbff Compare December 19, 2023 01:23

This comment has been minimized.

@gusinacio gusinacio force-pushed the gusinacio/state-machine-refactor branch 2 times, most recently from dc7a3c7 to 674404d Compare December 19, 2023 01:36

This comment has been minimized.

@gusinacio gusinacio force-pushed the gusinacio/state-machine-refactor branch from 674404d to 9582606 Compare December 19, 2023 01:39

This comment has been minimized.

Signed-off-by: Gustavo Inacio <gustavo@semiotic.ai>
@gusinacio gusinacio force-pushed the gusinacio/state-machine-refactor branch from 9582606 to 89b5d94 Compare December 19, 2023 01:40

This comment has been minimized.

@gusinacio gusinacio self-assigned this Dec 19, 2023

This comment has been minimized.

Signed-off-by: Gustavo Inacio <gustavo@semiotic.ai>

This comment has been minimized.

@gusinacio gusinacio marked this pull request as ready for review December 19, 2023 16:02
@gusinacio gusinacio requested a review from aasseman as a code owner December 19, 2023 16:02

This comment has been minimized.

Copy link
Contributor

@aasseman aasseman left a comment

Choose a reason for hiding this comment

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

Impressive

tap_core/src/tap_receipt/received_receipt.rs Outdated Show resolved Hide resolved
tap_core/src/tap_receipt/received_receipt.rs Outdated Show resolved Hide resolved
Signed-off-by: Gustavo Inacio <gustavo@semiotic.ai>
@gusinacio gusinacio requested a review from aasseman December 22, 2023 18:04
Signed-off-by: Gustavo Inacio <gustavo@semiotic.ai>
@gusinacio gusinacio force-pushed the gusinacio/state-machine-refactor branch from bc44a99 to 8616d13 Compare December 22, 2023 18:05

This comment has been minimized.

1 similar comment
Copy link

🤖 Cargo Audit Report 🤖

(Empty means OK! 👍)

Copy link
Contributor

@aasseman aasseman left a comment

Choose a reason for hiding this comment

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

:shipit:

@gusinacio gusinacio merged commit d841a44 into main Dec 22, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants