Skip to content

Commit 64b4e75

Browse files
committed
add delay between create contract and cancel it && add tearDown in all tests
1 parent 879f7f5 commit 64b4e75

File tree

9 files changed

+65
-0
lines changed

9 files changed

+65
-0
lines changed

packages/tfchain_client/test/balances_test.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ void main() {
1212
await queryClient.connect();
1313
});
1414

15+
tearDown(() async {
16+
await queryClient.disconnect();
17+
});
18+
1519
test('Test Get Balance', () async {
1620
String address = "5CJrCjZvsudNoJApTGG5PKcZfhAzAyGqgSK8bysoCV2oRBMC";
1721
AccountInfo? accountInfo =
@@ -43,6 +47,10 @@ void main() {
4347
await client.connect();
4448
});
4549

50+
tearDown(() async {
51+
await client.disconnect();
52+
});
53+
4654
test('Test Transfer TFTs with invalid amount', () async {
4755
try {
4856
await client.balances.transfer(

packages/tfchain_client/test/client_test.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ void main() {
2121
await queryClient.connect();
2222
});
2323

24+
tearDown(() async {
25+
await queryClient.disconnect();
26+
});
27+
2428
test('Initialization', () {
2529
expect(queryClient.url, equals("wss://tfchain.dev.grid.tf/ws"));
2630
expect(queryClient.contracts, isA<QueryContracts>());
@@ -56,6 +60,10 @@ void main() {
5660
await client.connect();
5761
});
5862

63+
tearDown(() async {
64+
await client.disconnect();
65+
});
66+
5967
test('Initialization', () {
6068
expect(client.url, equals("wss://tfchain.dev.grid.tf/ws"));
6169
expect(client.contracts, isA<Contracts>());

packages/tfchain_client/test/contracts_test.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ void main() {
1313
await queryClient.connect();
1414
});
1515

16+
tearDown(() async {
17+
await queryClient.disconnect();
18+
});
19+
1620
test('Test Get Deleted Contract by Id', () async {
1721
Contract? contract =
1822
await queryClient.contracts.get(contractId: BigInt.from(97897));
@@ -107,6 +111,10 @@ void main() {
107111
await client.connect();
108112
});
109113

114+
tearDown(() async {
115+
await client.disconnect();
116+
});
117+
110118
test('Test Create Node Contract with empty data', () async {
111119
try {
112120
BigInt? contractId = await client.contracts.createNode(
@@ -128,6 +136,7 @@ void main() {
128136
test('Test Create Name Contract then cancel it', () async {
129137
BigInt? contractId = await client.contracts.createName(name: "xxx");
130138
expect(contractId, isNotNull);
139+
await Future.delayed(Duration(seconds: 5));
131140
try {
132141
await client.contracts.cancel(contractId: contractId!);
133142
} catch (error) {

packages/tfchain_client/test/farms_test.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ void main() {
1313
await queryClient.connect();
1414
});
1515

16+
tearDown(() async {
17+
await queryClient.disconnect();
18+
});
19+
1620
test('Test Get Farm by Id', () async {
1721
Farm? farm = await queryClient.farms.get(id: 1);
1822
expect(farm, isNotNull);
@@ -38,6 +42,10 @@ void main() {
3842
client = Client(link, mnemonic, type);
3943
await client.connect();
4044
});
45+
46+
tearDown(() async {
47+
await client.disconnect();
48+
});
4149

4250
test('Test create farm', () async {
4351
final random = Random();

packages/tfchain_client/test/nodes_test.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ void main() {
1212
await queryClient.connect();
1313
});
1414

15+
tearDown(() async {
16+
await queryClient.disconnect();
17+
});
18+
1519
test('Test get Node by Id', () async {
1620
Node? node = await queryClient.nodes.get(id: 11);
1721
expect(node, isNotNull);
@@ -38,6 +42,10 @@ void main() {
3842
await client.connect();
3943
});
4044

45+
tearDown(() async {
46+
await client.disconnect();
47+
});
48+
4149
test('Test Set Power to node not owned by me', () async {
4250
try {
4351
await client.nodes.setPower(nodeId: 72, power: true);

packages/tfchain_client/test/pricing_policies_test.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ void main() {
1010
await queryClient.connect();
1111
});
1212

13+
tearDown(() async {
14+
await queryClient.disconnect();
15+
});
16+
1317
test('Test Get Pricing Policy', () async {
1418
PricingPolicy? res = await queryClient.policies.get(id: 1);
1519
expect(res, isNotNull);

packages/tfchain_client/test/tft_bridge_test.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ void main() {
1111
await queryClient.connect();
1212
});
1313

14+
tearDown(() async {
15+
await queryClient.disconnect();
16+
});
17+
1418
test('Test Get Withdraw fee', () async {
1519
BigInt? fee = await queryClient.bridge.getWithdrawFee();
1620
expect(fee, isNotNull);
@@ -34,6 +38,10 @@ void main() {
3438
await client.connect();
3539
});
3640

41+
tearDown(() async {
42+
await client.disconnect();
43+
});
44+
3745
test('Test swap to stellar zero TFTs', () async {
3846
try {
3947
await client.bridge.swapToStellar(

packages/tfchain_client/test/tft_price_test.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ void main() {
99
await queryClient.connect();
1010
});
1111

12+
tearDown(() async {
13+
await queryClient.disconnect();
14+
});
15+
1216
test('Test Get TFT price', () async {
1317
final price = await queryClient.price.get();
1418
expect(price, isNotNull);

packages/tfchain_client/test/twins_test.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ void main() {
1212
await queryClient.connect();
1313
});
1414

15+
tearDown(() async {
16+
await queryClient.disconnect();
17+
});
18+
1519
test('Test Get Twin with id', () async {
1620
int id = 214;
1721
final twin = await queryClient.twins.get(id: id);
@@ -44,6 +48,10 @@ void main() {
4448
await client.connect();
4549
});
4650

51+
tearDown(() async {
52+
await client.disconnect();
53+
});
54+
4755
test('Test Create Twin', () async {
4856
try {
4957
int? twin = await client.twins.create(relay: [], pk: []);

0 commit comments

Comments
 (0)