Skip to content

Commit

Permalink
Fix GitHub Actions (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
meeragjoshi authored Sep 14, 2023
1 parent b4a5090 commit 072c7e9
Show file tree
Hide file tree
Showing 14 changed files with 204 additions and 127 deletions.
24 changes: 19 additions & 5 deletions .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
steps:
- name: Clone the repository
uses: actions/checkout@v1

- name: Install Tools
run: sudo apt update && sudo apt install lcov

Expand All @@ -29,18 +29,32 @@ jobs:
ls -al "$GITHUB_WORKSPACE/../flutter/bin"
echo "$GITHUB_WORKSPACE/../flutter/bin" >> $GITHUB_PATH
echo "$GITHUB_WORKSPACE/../flutter/bin/cache/dart-sdk/bin" >> $GITHUB_PATH
- name: Populate the Flutter tool's cache of binary artifacts
run: |
flutter config --no-analytics
flutter precache
- name: Reconfigure git to use HTTP authentication
run: >
git config --global url."https://github.com/".insteadOf 'git@github.com:'
- name: Get Flutter packages
run: flutter pub get

- name: Run tests
run: flutter test --coverage
- name: Run simulator tests
run: bash ./integration_test/run_tests.sh

- name: Run unit tests
run: flutter test test --coverage --coverage-path=coverage/test.info

- name: Merge coverage files
run: |
lcov --add-tracefile coverage/test.info --add-tracefile coverage/integration_test.info --output-file coverage/merged_coverage.info
rm -rf coverage/*test.info
- name: Generate coverate report
run: genhtml coverage/lcov.info -o coverage
- name: Generate coverage report
run: genhtml coverage/merged_coverage.info -o coverage

- name: Upload code coverage to GitHub
uses: actions/upload-artifact@27121b0bdffd731efa15d66772be8dc71245d074
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@Timeout(Duration(minutes: 5))
@Skip('These are interactive tests using Chia Lite Wallet')
@Timeout(Duration(minutes: 5))
import 'package:chia_crypto_utils/chia_crypto_utils.dart';
import 'package:test/test.dart';
import 'package:walletconnect_flutter_v2/apis/core/core.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@Skip('These tests should be run manually, as they depend on the WalletConnect relay server')
@Timeout(Duration(minutes: 5))
import 'package:chia_crypto_utils/chia_crypto_utils.dart';
import 'package:test/test.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@Skip('These tests should be run manually, as they depend on the WalletConnect relay server')
@Timeout(Duration(minutes: 5))
import 'package:chia_crypto_utils/chia_crypto_utils.dart';
import 'package:test/test.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@Skip('These tests should be run manually, as they depend on the WalletConnect relay server')
@Timeout(Duration(minutes: 5))
import 'package:chia_crypto_utils/chia_crypto_utils.dart';
import 'package:test/test.dart';
Expand Down
1 change: 1 addition & 0 deletions integration_test/cat/cat_multi_issuance_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@Timeout(Duration(minutes: 5))
import 'package:chia_crypto_utils/chia_crypto_utils.dart';
import 'package:test/test.dart';

Expand Down
232 changes: 112 additions & 120 deletions integration_test/cat/coin_splitting_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Future<void> main() async {
blockchainUtils: SimulatorBlockchainUtils(fullNodeSimulator),
);

const desiredNumberOfCoins = 91;

late ChiaEnthusiast meera;

setUp(() async {
Expand All @@ -34,7 +36,7 @@ Future<void> main() async {
keychain: meera.keychain,
splitWidth: 3,
feePerCoin: 10000,
desiredNumberOfCoins: 91,
desiredNumberOfCoins: desiredNumberOfCoins,
desiredAmountPerCoin: 101,
changePuzzlehash: meera.firstPuzzlehash,
);
Expand All @@ -51,121 +53,113 @@ Future<void> main() async {
test('should throw error when cat balance is not enough to meet desired splitting parameters',
() async {
//cat coin balance is 100000000
expect(
() async {
await coinSplittingService.splitCoins(
catCoinToSplit: meera.catCoins[0],
standardCoinsForFee: meera.standardCoins,
keychain: meera.keychain,
splitWidth: 3,
feePerCoin: 1000,
desiredNumberOfCoins: 91,
desiredAmountPerCoin: 10000000,
changePuzzlehash: meera.firstPuzzlehash,
);
},
throwsArgumentError,
);

try {
await coinSplittingService.splitCoins(
catCoinToSplit: meera.catCoins[0],
standardCoinsForFee: meera.standardCoins,
keychain: meera.keychain,
splitWidth: 3,
feePerCoin: 1000,
desiredNumberOfCoins: desiredNumberOfCoins,
desiredAmountPerCoin: 10000000,
changePuzzlehash: meera.firstPuzzlehash,
);
} catch (e) {
expect(e, isA<ArgumentError>());
}
});

test(
'should throw error when cat balance is just barely not enough to meet desired splitting parameters',
() async {
expect(
() async {
await coinSplittingService.splitCoins(
catCoinToSplit: meera.catCoins[0],
standardCoinsForFee: meera.standardCoins,
keychain: meera.keychain,
splitWidth: 3,
feePerCoin: 1000,
desiredNumberOfCoins: 91,
desiredAmountPerCoin: 1111112,
changePuzzlehash: meera.firstPuzzlehash,
);
},
throwsArgumentError,
);
try {
await coinSplittingService.splitCoins(
catCoinToSplit: meera.catCoins[0],
standardCoinsForFee: meera.standardCoins,
keychain: meera.keychain,
splitWidth: 3,
feePerCoin: 1000,
desiredNumberOfCoins: desiredNumberOfCoins,
desiredAmountPerCoin: 1111112,
changePuzzlehash: meera.firstPuzzlehash,
);
} catch (e) {
expect(e, isA<ArgumentError>());
}
});

test('should work when cat balance is just barely enough to meet desired splitting parameters',
() async {
expect(
() async {
await coinSplittingService.splitCoins(
catCoinToSplit: meera.catCoins[0],
standardCoinsForFee: meera.standardCoins,
keychain: meera.keychain,
splitWidth: 3,
feePerCoin: 1000,
desiredNumberOfCoins: 91,
desiredAmountPerCoin: 1111111,
changePuzzlehash: meera.firstPuzzlehash,
);
},
returnsNormally,
final returnedNumberOfCoins = await coinSplittingService.splitCoins(
catCoinToSplit: meera.catCoins[0],
standardCoinsForFee: meera.standardCoins,
keychain: meera.keychain,
splitWidth: 3,
feePerCoin: 1000,
desiredNumberOfCoins: desiredNumberOfCoins,
desiredAmountPerCoin: 111111,
changePuzzlehash: meera.firstPuzzlehash,
);

expect(returnedNumberOfCoins, equals(desiredNumberOfCoins));
});

test(
'should throw error when standard balance is not enough to meet desired splitting parameters',
() async {
//standard balance is 1999900000000
expect(
() async {
await coinSplittingService.splitCoins(
catCoinToSplit: meera.catCoins[0],
standardCoinsForFee: meera.standardCoins,
keychain: meera.keychain,
splitWidth: 3,
feePerCoin: 50000000000,
desiredNumberOfCoins: 91,
desiredAmountPerCoin: 101,
changePuzzlehash: meera.firstPuzzlehash,
);
},
throwsArgumentError,
);
// standard balance is 1999900000000

try {
await coinSplittingService.splitCoins(
catCoinToSplit: meera.catCoins[0],
standardCoinsForFee: meera.standardCoins,
keychain: meera.keychain,
splitWidth: 3,
feePerCoin: 50000000000,
desiredNumberOfCoins: desiredNumberOfCoins,
desiredAmountPerCoin: 101,
changePuzzlehash: meera.firstPuzzlehash,
);
} catch (e) {
expect(e, isA<ArgumentError>());
}
});

test(
'should throw error when standard balance is just barely not enough to meet desired splitting parameters',
() async {
expect(
() async {
await coinSplittingService.splitCoins(
catCoinToSplit: meera.catCoins[0],
standardCoinsForFee: meera.standardCoins,
keychain: meera.keychain,
splitWidth: 3,
feePerCoin: 8583261803,
desiredNumberOfCoins: 91,
desiredAmountPerCoin: 101,
changePuzzlehash: meera.firstPuzzlehash,
);
},
throwsArgumentError,
);
try {
await coinSplittingService.splitCoins(
catCoinToSplit: meera.catCoins[0],
standardCoinsForFee: meera.standardCoins,
keychain: meera.keychain,
splitWidth: 3,
feePerCoin: 8583261803,
desiredNumberOfCoins: desiredNumberOfCoins,
desiredAmountPerCoin: 101,
changePuzzlehash: meera.firstPuzzlehash,
);
} catch (e) {
expect(e, isA<ArgumentError>());
}
});

test(
'should work when standard balance is just barely enough to meet desired splitting parameters',
() async {
expect(
() async {
await coinSplittingService.splitCoins(
catCoinToSplit: meera.catCoins[0],
standardCoinsForFee: meera.standardCoins,
keychain: meera.keychain,
splitWidth: 3,
feePerCoin: 8583261802,
desiredNumberOfCoins: 91,
desiredAmountPerCoin: 101,
changePuzzlehash: meera.firstPuzzlehash,
);
},
returnsNormally,
final returnedNumberOfCoins = await coinSplittingService.splitCoins(
catCoinToSplit: meera.catCoins[0],
standardCoinsForFee: meera.standardCoins,
keychain: meera.keychain,
splitWidth: 3,
feePerCoin: 200000000,
desiredNumberOfCoins: desiredNumberOfCoins,
desiredAmountPerCoin: 101,
changePuzzlehash: meera.firstPuzzlehash,
);

expect(returnedNumberOfCoins, equals(returnedNumberOfCoins));
});

test('should throw error when there are not enough puzzlehashes to cover split width', () async {
Expand All @@ -174,21 +168,20 @@ Future<void> main() async {
await nathan.farmCoins();
await nathan.issueMultiIssuanceCat(nathan.keychainSecret.masterPrivateKey);

expect(
() async {
await coinSplittingService.splitCoins(
catCoinToSplit: nathan.catCoins[0],
standardCoinsForFee: nathan.standardCoins,
keychain: nathan.keychain,
splitWidth: 3,
feePerCoin: 10000,
desiredNumberOfCoins: 91,
desiredAmountPerCoin: 101,
changePuzzlehash: nathan.firstPuzzlehash,
);
},
throwsArgumentError,
);
try {
await coinSplittingService.splitCoins(
catCoinToSplit: nathan.catCoins[0],
standardCoinsForFee: nathan.standardCoins,
keychain: nathan.keychain,
splitWidth: 3,
feePerCoin: 10000,
desiredNumberOfCoins: desiredNumberOfCoins,
desiredAmountPerCoin: 101,
changePuzzlehash: nathan.firstPuzzlehash,
);
} catch (e) {
expect(e, isA<ArgumentError>());
}
});

test(
Expand All @@ -198,20 +191,19 @@ Future<void> main() async {
await nathan.farmCoins();
await nathan.issueMultiIssuanceCat(nathan.keychainSecret.masterPrivateKey);

expect(
() async {
await coinSplittingService.splitCoins(
catCoinToSplit: nathan.catCoins[0],
standardCoinsForFee: nathan.standardCoins,
keychain: nathan.keychain,
splitWidth: 3,
feePerCoin: 10000,
desiredNumberOfCoins: 91,
desiredAmountPerCoin: 101,
changePuzzlehash: nathan.firstPuzzlehash,
);
},
throwsArgumentError,
);
try {
await coinSplittingService.splitCoins(
catCoinToSplit: nathan.catCoins[0],
standardCoinsForFee: nathan.standardCoins,
keychain: nathan.keychain,
splitWidth: 3,
feePerCoin: 10000,
desiredNumberOfCoins: desiredNumberOfCoins,
desiredAmountPerCoin: 101,
changePuzzlehash: nathan.firstPuzzlehash,
);
} catch (e) {
expect(e, isA<ArgumentError>());
}
});
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@Timeout(Duration(minutes: 3))
@Timeout(Duration(minutes: 5))
import 'dart:async';
import 'dart:math';

Expand Down
Loading

0 comments on commit 072c7e9

Please sign in to comment.