mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 03:49:22 +00:00
Fix and test the rest of the tests
This commit is contained in:
parent
be64df3315
commit
a0e38aab31
1 changed files with 129 additions and 129 deletions
|
@ -376,91 +376,91 @@ void main() {
|
||||||
verifyNoMoreInteractions(priceAPI);
|
verifyNoMoreInteractions(priceAPI);
|
||||||
});
|
});
|
||||||
|
|
||||||
// test("estimateTxFee", () async {
|
test("estimateTxFee", () async {
|
||||||
// expect(part?.estimateTxFee(vSize: 356, feeRatePerKB: 1), 356);
|
expect(part?.estimateTxFee(vSize: 356, feeRatePerKB: 1), 356);
|
||||||
// expect(part?.estimateTxFee(vSize: 356, feeRatePerKB: 900), 356);
|
expect(part?.estimateTxFee(vSize: 356, feeRatePerKB: 900), 356);
|
||||||
// expect(part?.estimateTxFee(vSize: 356, feeRatePerKB: 999), 356);
|
expect(part?.estimateTxFee(vSize: 356, feeRatePerKB: 999), 356);
|
||||||
// expect(part?.estimateTxFee(vSize: 356, feeRatePerKB: 1000), 356);
|
expect(part?.estimateTxFee(vSize: 356, feeRatePerKB: 1000), 356);
|
||||||
// expect(part?.estimateTxFee(vSize: 356, feeRatePerKB: 1001), 712);
|
expect(part?.estimateTxFee(vSize: 356, feeRatePerKB: 1001), 712);
|
||||||
// expect(part?.estimateTxFee(vSize: 356, feeRatePerKB: 1699), 712);
|
expect(part?.estimateTxFee(vSize: 356, feeRatePerKB: 1699), 712);
|
||||||
// expect(part?.estimateTxFee(vSize: 356, feeRatePerKB: 2000), 712);
|
expect(part?.estimateTxFee(vSize: 356, feeRatePerKB: 2000), 712);
|
||||||
// expect(part?.estimateTxFee(vSize: 356, feeRatePerKB: 12345), 4628);
|
expect(part?.estimateTxFee(vSize: 356, feeRatePerKB: 12345), 4628);
|
||||||
// expect(secureStore.interactions, 0);
|
expect(secureStore.interactions, 0);
|
||||||
// verifyNoMoreInteractions(client);
|
verifyNoMoreInteractions(client);
|
||||||
// verifyNoMoreInteractions(cachedClient);
|
verifyNoMoreInteractions(cachedClient);
|
||||||
// verifyNoMoreInteractions(priceAPI);
|
verifyNoMoreInteractions(priceAPI);
|
||||||
// });
|
});
|
||||||
|
|
||||||
// test("get fees succeeds", () async {
|
test("get fees succeeds", () async {
|
||||||
// when(client?.ping()).thenAnswer((_) async => true);
|
when(client?.ping()).thenAnswer((_) async => true);
|
||||||
// when(client?.getServerFeatures()).thenAnswer((_) async => {
|
when(client?.getServerFeatures()).thenAnswer((_) async => {
|
||||||
// "hosts": {},
|
"hosts": {},
|
||||||
// "pruning": null,
|
"pruning": null,
|
||||||
// "server_version": "Unit tests",
|
"server_version": "Unit tests",
|
||||||
// "protocol_min": "1.4",
|
"protocol_min": "1.4",
|
||||||
// "protocol_max": "1.4.2",
|
"protocol_max": "1.4.2",
|
||||||
// "genesis_hash": GENESIS_HASH_MAINNET,
|
"genesis_hash": GENESIS_HASH_MAINNET,
|
||||||
// "hash_function": "sha256",
|
"hash_function": "sha256",
|
||||||
// "services": []
|
"services": []
|
||||||
// });
|
});
|
||||||
// when(client?.estimateFee(blocks: 1))
|
when(client?.estimateFee(blocks: 1))
|
||||||
// .thenAnswer((realInvocation) async => Decimal.zero);
|
.thenAnswer((realInvocation) async => Decimal.zero);
|
||||||
// when(client?.estimateFee(blocks: 5))
|
when(client?.estimateFee(blocks: 5))
|
||||||
// .thenAnswer((realInvocation) async => Decimal.one);
|
.thenAnswer((realInvocation) async => Decimal.one);
|
||||||
// when(client?.estimateFee(blocks: 20))
|
when(client?.estimateFee(blocks: 20))
|
||||||
// .thenAnswer((realInvocation) async => Decimal.ten);
|
.thenAnswer((realInvocation) async => Decimal.ten);
|
||||||
//
|
|
||||||
// final fees = await part?.fees;
|
|
||||||
// expect(fees, isA<FeeObject>());
|
|
||||||
// expect(fees?.slow, 1000000000);
|
|
||||||
// expect(fees?.medium, 100000000);
|
|
||||||
// expect(fees?.fast, 0);
|
|
||||||
//
|
|
||||||
// verify(client?.estimateFee(blocks: 1)).called(1);
|
|
||||||
// verify(client?.estimateFee(blocks: 5)).called(1);
|
|
||||||
// verify(client?.estimateFee(blocks: 20)).called(1);
|
|
||||||
// expect(secureStore.interactions, 0);
|
|
||||||
// verifyNoMoreInteractions(client);
|
|
||||||
// verifyNoMoreInteractions(cachedClient);
|
|
||||||
// verifyNoMoreInteractions(priceAPI);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// test("get fees fails", () async {
|
final fees = await part?.fees;
|
||||||
// when(client?.ping()).thenAnswer((_) async => true);
|
expect(fees, isA<FeeObject>());
|
||||||
// when(client?.getServerFeatures()).thenAnswer((_) async => {
|
expect(fees?.slow, 1000000000);
|
||||||
// "hosts": {},
|
expect(fees?.medium, 100000000);
|
||||||
// "pruning": null,
|
expect(fees?.fast, 0);
|
||||||
// "server_version": "Unit tests",
|
|
||||||
// "protocol_min": "1.4",
|
verify(client?.estimateFee(blocks: 1)).called(1);
|
||||||
// "protocol_max": "1.4.2",
|
verify(client?.estimateFee(blocks: 5)).called(1);
|
||||||
// "genesis_hash": GENESIS_HASH_MAINNET,
|
verify(client?.estimateFee(blocks: 20)).called(1);
|
||||||
// "hash_function": "sha256",
|
expect(secureStore.interactions, 0);
|
||||||
// "services": []
|
verifyNoMoreInteractions(client);
|
||||||
// });
|
verifyNoMoreInteractions(cachedClient);
|
||||||
// when(client?.estimateFee(blocks: 1))
|
verifyNoMoreInteractions(priceAPI);
|
||||||
// .thenAnswer((realInvocation) async => Decimal.zero);
|
});
|
||||||
// when(client?.estimateFee(blocks: 5))
|
|
||||||
// .thenAnswer((realInvocation) async => Decimal.one);
|
test("get fees fails", () async {
|
||||||
// when(client?.estimateFee(blocks: 20))
|
when(client?.ping()).thenAnswer((_) async => true);
|
||||||
// .thenThrow(Exception("some exception"));
|
when(client?.getServerFeatures()).thenAnswer((_) async => {
|
||||||
//
|
"hosts": {},
|
||||||
// bool didThrow = false;
|
"pruning": null,
|
||||||
// try {
|
"server_version": "Unit tests",
|
||||||
// await part?.fees;
|
"protocol_min": "1.4",
|
||||||
// } catch (_) {
|
"protocol_max": "1.4.2",
|
||||||
// didThrow = true;
|
"genesis_hash": GENESIS_HASH_MAINNET,
|
||||||
// }
|
"hash_function": "sha256",
|
||||||
//
|
"services": []
|
||||||
// expect(didThrow, true);
|
});
|
||||||
//
|
when(client?.estimateFee(blocks: 1))
|
||||||
// verify(client?.estimateFee(blocks: 1)).called(1);
|
.thenAnswer((realInvocation) async => Decimal.zero);
|
||||||
// verify(client?.estimateFee(blocks: 5)).called(1);
|
when(client?.estimateFee(blocks: 5))
|
||||||
// verify(client?.estimateFee(blocks: 20)).called(1);
|
.thenAnswer((realInvocation) async => Decimal.one);
|
||||||
// expect(secureStore.interactions, 0);
|
when(client?.estimateFee(blocks: 20))
|
||||||
// verifyNoMoreInteractions(client);
|
.thenThrow(Exception("some exception"));
|
||||||
// verifyNoMoreInteractions(cachedClient);
|
|
||||||
// verifyNoMoreInteractions(priceAPI);
|
bool didThrow = false;
|
||||||
// });
|
try {
|
||||||
|
await part?.fees;
|
||||||
|
} catch (_) {
|
||||||
|
didThrow = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(didThrow, true);
|
||||||
|
|
||||||
|
verify(client?.estimateFee(blocks: 1)).called(1);
|
||||||
|
verify(client?.estimateFee(blocks: 5)).called(1);
|
||||||
|
verify(client?.estimateFee(blocks: 20)).called(1);
|
||||||
|
expect(secureStore.interactions, 0);
|
||||||
|
verifyNoMoreInteractions(client);
|
||||||
|
verifyNoMoreInteractions(cachedClient);
|
||||||
|
verifyNoMoreInteractions(priceAPI);
|
||||||
|
});
|
||||||
|
|
||||||
// test("get maxFee", () async {
|
// test("get maxFee", () async {
|
||||||
// when(client?.ping()).thenAnswer((_) async => true);
|
// when(client?.ping()).thenAnswer((_) async => true);
|
||||||
|
@ -481,7 +481,7 @@ void main() {
|
||||||
// when(client?.estimateFee(blocks: 1))
|
// when(client?.estimateFee(blocks: 1))
|
||||||
// .thenAnswer((realInvocation) async => Decimal.ten);
|
// .thenAnswer((realInvocation) async => Decimal.ten);
|
||||||
//
|
//
|
||||||
// final maxFee = await nmc?.maxFee;
|
// final maxFee = await part?.maxFee;
|
||||||
// expect(maxFee, 1000000000);
|
// expect(maxFee, 1000000000);
|
||||||
//
|
//
|
||||||
// verify(client?.estimateFee(blocks: 1)).called(1);
|
// verify(client?.estimateFee(blocks: 1)).called(1);
|
||||||
|
@ -1427,52 +1427,52 @@ void main() {
|
||||||
verifyNoMoreInteractions(priceAPI);
|
verifyNoMoreInteractions(priceAPI);
|
||||||
});
|
});
|
||||||
|
|
||||||
// test("confirmSend fails due to vSize being greater than fee", () async {
|
test("confirmSend fails due to vSize being greater than fee", () async {
|
||||||
// bool didThrow = false;
|
bool didThrow = false;
|
||||||
// try {
|
try {
|
||||||
// await nmc
|
await part
|
||||||
// ?.confirmSend(txData: {"hex": "a string", "fee": 1, "vSize": 10});
|
?.confirmSend(txData: {"hex": "a string", "fee": 1, "vSize": 10});
|
||||||
// } catch (_) {
|
} catch (_) {
|
||||||
// didThrow = true;
|
didThrow = true;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// expect(didThrow, true);
|
|
||||||
//
|
|
||||||
// verify(client?.broadcastTransaction(
|
|
||||||
// rawTx: "a string", requestID: anyNamed("requestID")))
|
|
||||||
// .called(1);
|
|
||||||
//
|
|
||||||
// expect(secureStore.interactions, 0);
|
|
||||||
// verifyNoMoreInteractions(client);
|
|
||||||
// verifyNoMoreInteractions(cachedClient);
|
|
||||||
// verifyNoMoreInteractions(priceAPI);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// test("confirmSend fails when broadcast transactions throws", () async {
|
expect(didThrow, true);
|
||||||
// when(client?.broadcastTransaction(
|
|
||||||
// rawTx: "a string", requestID: anyNamed("requestID")))
|
verify(client?.broadcastTransaction(
|
||||||
// .thenThrow(Exception("some exception"));
|
rawTx: "a string", requestID: anyNamed("requestID")))
|
||||||
//
|
.called(1);
|
||||||
// bool didThrow = false;
|
|
||||||
// try {
|
expect(secureStore.interactions, 0);
|
||||||
// await nmc
|
verifyNoMoreInteractions(client);
|
||||||
// ?.confirmSend(txData: {"hex": "a string", "fee": 10, "vSize": 10});
|
verifyNoMoreInteractions(cachedClient);
|
||||||
// } catch (_) {
|
verifyNoMoreInteractions(priceAPI);
|
||||||
// didThrow = true;
|
});
|
||||||
// }
|
|
||||||
//
|
test("confirmSend fails when broadcast transactions throws", () async {
|
||||||
// expect(didThrow, true);
|
when(client?.broadcastTransaction(
|
||||||
//
|
rawTx: "a string", requestID: anyNamed("requestID")))
|
||||||
// verify(client?.broadcastTransaction(
|
.thenThrow(Exception("some exception"));
|
||||||
// rawTx: "a string", requestID: anyNamed("requestID")))
|
|
||||||
// .called(1);
|
bool didThrow = false;
|
||||||
//
|
try {
|
||||||
// expect(secureStore.interactions, 0);
|
await part
|
||||||
// verifyNoMoreInteractions(client);
|
?.confirmSend(txData: {"hex": "a string", "fee": 10, "vSize": 10});
|
||||||
// verifyNoMoreInteractions(cachedClient);
|
} catch (_) {
|
||||||
// verifyNoMoreInteractions(tracker);
|
didThrow = true;
|
||||||
// verifyNoMoreInteractions(priceAPI);
|
}
|
||||||
// });
|
|
||||||
|
expect(didThrow, true);
|
||||||
|
|
||||||
|
verify(client?.broadcastTransaction(
|
||||||
|
rawTx: "a string", requestID: anyNamed("requestID")))
|
||||||
|
.called(1);
|
||||||
|
|
||||||
|
expect(secureStore.interactions, 0);
|
||||||
|
verifyNoMoreInteractions(client);
|
||||||
|
verifyNoMoreInteractions(cachedClient);
|
||||||
|
verifyNoMoreInteractions(tracker);
|
||||||
|
verifyNoMoreInteractions(priceAPI);
|
||||||
|
});
|
||||||
//
|
//
|
||||||
// // this test will create a non mocked electrumx client that will try to connect
|
// // this test will create a non mocked electrumx client that will try to connect
|
||||||
// // to the provided ipAddress below. This will throw a bunch of errors
|
// // to the provided ipAddress below. This will throw a bunch of errors
|
||||||
|
|
Loading…
Reference in a new issue