-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into pi/SSW-306-efficient-…
…sqrt
- Loading branch information
Showing
10 changed files
with
1,035 additions
and
706 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,33 @@ jobs: | |
|
||
- uses: aiken-lang/[email protected] | ||
with: | ||
version: v1.0.20-alpha | ||
version: v1.0.24-alpha | ||
|
||
- run: aiken check | ||
- run: | | ||
# Run the tests | ||
set -o pipefail | ||
RESULT=0 | ||
aiken check 2>&1 | tee aiken.log || RESULT=$? | ||
if [ $RESULT -ne 0 ]; then | ||
{ | ||
echo 'FAILING_TESTS<<EOF' | ||
grep "FAIL" aiken.log | ||
echo EOF | ||
} >> "$GITHUB_ENV" | ||
cat $GITHUB_ENV | ||
exit $RESULT | ||
fi | ||
- if: failure() | ||
run: | | ||
echo "$FAILING_TESTS" | ||
- run: aiken build | ||
- uses: actions/github-script@v6 | ||
if: failure() && env.FAILING_TESTS != '' | ||
with: | ||
script: | | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: `Tests failed:\n\n\`\`\`\n${{ env.FAILING_TESTS }}\n\`\`\`` | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
use aiken/transaction.{NoDatum, Output} | ||
use aiken/transaction/credential.{Address, VerificationKeyCredential} | ||
use aiken/transaction/value | ||
use calculation/shared.{PoolState} as calc_shared | ||
use calculation/donation.{do_donation} | ||
use sundae/multisig | ||
use types/order.{Destination, OrderDatum} | ||
|
||
test donation() { | ||
let addr = | ||
Address( | ||
VerificationKeyCredential( | ||
#"6af53ff4f054348ad825c692dd9db8f1760a8e0eacf9af9f99306513", | ||
), | ||
None, | ||
) | ||
let ada = (#"", #"") | ||
let rberry = | ||
(#"01010101010101010101010101010101010101010101010101010101", "RBERRY") | ||
let lp = (#"99999999999999999999999999999999999999999999999999999999", "LP") | ||
let pool_state = | ||
PoolState { | ||
quantity_a: (#"", #"", 1_000_000_000), | ||
quantity_b: (rberry.1st, rberry.2nd, 1_000_000_000), | ||
quantity_lp: (lp.1st, lp.2nd, 1_000_000_000), | ||
} | ||
let input_value = | ||
value.from_lovelace(3_500_000) | ||
|> value.add(rberry.1st, rberry.2nd, 1_000_000) | ||
let assets = ( | ||
(ada.1st, ada.2nd, 1_000_000), | ||
(rberry.1st, rberry.2nd, 1_000_000), | ||
) | ||
let order = | ||
OrderDatum { | ||
pool_ident: None, | ||
owner: multisig.Signature( | ||
#"6af53ff4f054348ad825c692dd9db8f1760a8e0eacf9af9f99306513", | ||
), | ||
max_protocol_fee: 2_500_000, | ||
destination: Destination { address: addr, datum: NoDatum }, | ||
details: order.Donation { | ||
assets: assets, | ||
}, | ||
extension: Void, | ||
} | ||
// There's no remainder so do_donation totally ignores this Output record | ||
let output = | ||
Output { | ||
address: addr, | ||
value: value.from_lovelace(999_999_999_999_999_999), | ||
datum: NoDatum, | ||
reference_script: None, | ||
} | ||
let (final_pool_state, has_remainder) = | ||
do_donation(pool_state, input_value, assets, order.destination, 2_500_000, output) | ||
expect !has_remainder | ||
expect final_pool_state.quantity_a.3rd == 1_001_000_000 | ||
expect final_pool_state.quantity_b.3rd == 1_001_000_000 | ||
True | ||
} |
Oops, something went wrong.