Skip to content

Commit 079297d

Browse files
author
Baha
committed
fix: empty values refactored in unit tests
1 parent 523ba51 commit 079297d

File tree

3 files changed

+42
-33
lines changed

3 files changed

+42
-33
lines changed

test/model/transaction/AccountMetadataTransaction.spec.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,23 @@ import { UInt64 } from '../../../src/model/UInt64';
2828
import { TestingAccount, TestNetworkType } from '../../conf/conf.spec';
2929

3030
describe('AccountMetadataTransaction', () => {
31-
let account: Account;
31+
let account: Account, emptyValue: Uint8Array;
3232
const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6';
3333
const epochAdjustment = 1573430400;
3434
before(() => {
3535
account = TestingAccount;
3636
});
37+
beforeEach(() => {
38+
emptyValue = new Uint8Array(10);
39+
});
3740

3841
it('should default maxFee field be set to 0', () => {
3942
const accountMetadataTransaction = AccountMetadataTransaction.create(
4043
Deadline.create(epochAdjustment),
4144
account.address,
4245
UInt64.fromUint(1000),
4346
1,
44-
new Uint8Array(10),
47+
emptyValue,
4548
TestNetworkType,
4649
);
4750

@@ -55,7 +58,7 @@ describe('AccountMetadataTransaction', () => {
5558
account.address,
5659
UInt64.fromUint(1000),
5760
1,
58-
new Uint8Array(10),
61+
emptyValue,
5962
TestNetworkType,
6063
new UInt64([1, 0]),
6164
);
@@ -70,7 +73,7 @@ describe('AccountMetadataTransaction', () => {
7073
account.address,
7174
UInt64.fromUint(1000),
7275
1,
73-
new Uint8Array(10),
76+
emptyValue,
7477
TestNetworkType,
7578
);
7679

@@ -88,7 +91,7 @@ describe('AccountMetadataTransaction', () => {
8891
account.address,
8992
UInt64.fromUint(1000),
9093
1,
91-
new Uint8Array(10),
94+
emptyValue,
9295
TestNetworkType,
9396
);
9497

@@ -105,7 +108,7 @@ describe('AccountMetadataTransaction', () => {
105108
account.address,
106109
UInt64.fromUint(1000),
107110
1,
108-
new Uint8Array(10),
111+
emptyValue,
109112
TestNetworkType,
110113
);
111114

@@ -122,7 +125,7 @@ describe('AccountMetadataTransaction', () => {
122125
account.address,
123126
UInt64.fromUint(1000),
124127
1,
125-
new Uint8Array(10),
128+
emptyValue,
126129
TestNetworkType,
127130
);
128131

@@ -141,7 +144,7 @@ describe('AccountMetadataTransaction', () => {
141144
account.address,
142145
UInt64.fromUint(1000),
143146
1,
144-
new Uint8Array(10),
147+
emptyValue,
145148
TestNetworkType,
146149
);
147150

@@ -157,7 +160,7 @@ describe('AccountMetadataTransaction', () => {
157160
account.address,
158161
UInt64.fromUint(1000),
159162
1,
160-
new Uint8Array(10),
163+
emptyValue,
161164
TestNetworkType,
162165
);
163166

@@ -179,7 +182,7 @@ describe('AccountMetadataTransaction', () => {
179182
alias,
180183
UInt64.fromUint(1000),
181184
1,
182-
new Uint8Array(10),
185+
emptyValue,
183186
TestNetworkType,
184187
);
185188

test/model/transaction/MosaicMetadataTransaction.spec.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import { UInt64 } from '../../../src/model/UInt64';
3434
import { TestingAccount, TestNetworkType } from '../../conf/conf.spec';
3535

3636
describe('MosaicMetadataTransaction', () => {
37-
let account: Account;
37+
let account: Account, emptyValue: Uint8Array;
3838
const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6';
3939
let statement: Statement;
4040
const unresolvedMosaicId = new NamespaceId('mosaic');
@@ -52,6 +52,9 @@ describe('MosaicMetadataTransaction', () => {
5252
],
5353
);
5454
});
55+
beforeEach(() => {
56+
emptyValue = new Uint8Array(10);
57+
});
5558

5659
it('should default maxFee field be set to 0', () => {
5760
const mosaicMetadataTransaction = MosaicMetadataTransaction.create(
@@ -60,7 +63,7 @@ describe('MosaicMetadataTransaction', () => {
6063
UInt64.fromUint(1000),
6164
new MosaicId([2262289484, 3405110546]),
6265
1,
63-
new Uint8Array(10),
66+
emptyValue,
6467
TestNetworkType,
6568
);
6669

@@ -75,7 +78,7 @@ describe('MosaicMetadataTransaction', () => {
7578
UInt64.fromUint(1000),
7679
new MosaicId([2262289484, 3405110546]),
7780
1,
78-
new Uint8Array(10),
81+
emptyValue,
7982
TestNetworkType,
8083
new UInt64([1, 0]),
8184
);
@@ -91,7 +94,7 @@ describe('MosaicMetadataTransaction', () => {
9194
UInt64.fromUint(1000),
9295
new MosaicId([2262289484, 3405110546]),
9396
1,
94-
new Uint8Array(10),
97+
emptyValue,
9598
TestNetworkType,
9699
);
97100

@@ -110,7 +113,7 @@ describe('MosaicMetadataTransaction', () => {
110113
UInt64.fromUint(1000),
111114
namespacId,
112115
1,
113-
new Uint8Array(10),
116+
emptyValue,
114117
TestNetworkType,
115118
);
116119

@@ -129,7 +132,7 @@ describe('MosaicMetadataTransaction', () => {
129132
UInt64.fromUint(1000),
130133
new MosaicId([2262289484, 3405110546]),
131134
1,
132-
new Uint8Array(10),
135+
emptyValue,
133136
TestNetworkType,
134137
);
135138
expect(mosaicMetadataTransaction.size).to.be.equal(182);
@@ -143,7 +146,7 @@ describe('MosaicMetadataTransaction', () => {
143146
UInt64.fromUint(1000),
144147
new MosaicId([2262289484, 3405110546]),
145148
1,
146-
new Uint8Array(10),
149+
emptyValue,
147150
TestNetworkType,
148151
);
149152
expect(mosaicMetadataTransaction.size).to.be.equal(182);
@@ -159,7 +162,7 @@ describe('MosaicMetadataTransaction', () => {
159162
UInt64.fromUint(1000),
160163
new MosaicId([2262289484, 3405110546]),
161164
1,
162-
new Uint8Array(10),
165+
emptyValue,
163166
TestNetworkType,
164167
).setMaxFee(2);
165168
expect(mosaicMetadataTransaction.maxFee.compact()).to.be.equal(364);
@@ -178,7 +181,7 @@ describe('MosaicMetadataTransaction', () => {
178181
UInt64.fromUint(1000),
179182
unresolvedMosaicId,
180183
10,
181-
new Uint8Array(10),
184+
emptyValue,
182185
'',
183186
account.publicAccount,
184187
new TransactionInfo(UInt64.fromUint(2), 0, ''),
@@ -197,7 +200,7 @@ describe('MosaicMetadataTransaction', () => {
197200
UInt64.fromUint(1000),
198201
new MosaicId([2262289484, 3405110546]),
199202
1,
200-
new Uint8Array(10),
203+
emptyValue,
201204
TestNetworkType,
202205
);
203206

@@ -217,7 +220,7 @@ describe('MosaicMetadataTransaction', () => {
217220
UInt64.fromUint(1000),
218221
new MosaicId([2262289484, 3405110546]),
219222
1,
220-
new Uint8Array(10),
223+
emptyValue,
221224
TestNetworkType,
222225
);
223226
let canNotify = tx.shouldNotifyAccount(account.address);
@@ -239,7 +242,7 @@ describe('MosaicMetadataTransaction', () => {
239242
UInt64.fromUint(1000),
240243
new MosaicId([2262289484, 3405110546]),
241244
1,
242-
new Uint8Array(10),
245+
emptyValue,
243246
TestNetworkType,
244247
);
245248
let canNotify = tx.shouldNotifyAccount(alias);

test/model/transaction/NamespaceMetadataTransaction.spec.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,15 @@ import { Deadline, NamespaceMetadataTransaction, TransactionType } from '../../.
2525
import { TestingAccount, TestNetworkType } from '../../conf/conf.spec';
2626

2727
describe('NamespaceMetadataTransaction', () => {
28-
let account: Account;
28+
let account: Account, emptyValue: Uint8Array;
2929
const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6';
3030
const epochAdjustment = 1573430400;
3131
before(() => {
3232
account = TestingAccount;
3333
});
34+
beforeEach(() => {
35+
emptyValue = new Uint8Array(10);
36+
});
3437

3538
it('should default maxFee field be set to 0', () => {
3639
const namespaceMetadataTransaction = NamespaceMetadataTransaction.create(
@@ -39,7 +42,7 @@ describe('NamespaceMetadataTransaction', () => {
3942
UInt64.fromUint(1000),
4043
new NamespaceId([2262289484, 3405110546]),
4144
1,
42-
new Uint8Array(10),
45+
emptyValue,
4346
TestNetworkType,
4447
);
4548

@@ -54,7 +57,7 @@ describe('NamespaceMetadataTransaction', () => {
5457
UInt64.fromUint(1000),
5558
new NamespaceId([2262289484, 3405110546]),
5659
1,
57-
new Uint8Array(10),
60+
emptyValue,
5861
TestNetworkType,
5962
new UInt64([1, 0]),
6063
);
@@ -70,7 +73,7 @@ describe('NamespaceMetadataTransaction', () => {
7073
UInt64.fromUint(1000),
7174
new NamespaceId([2262289484, 3405110546]),
7275
1,
73-
new Uint8Array(10),
76+
emptyValue,
7477
TestNetworkType,
7578
);
7679

@@ -89,7 +92,7 @@ describe('NamespaceMetadataTransaction', () => {
8992
UInt64.fromUint(1000),
9093
new NamespaceId([2262289484, 3405110546]),
9194
1,
92-
new Uint8Array(10),
95+
emptyValue,
9396
TestNetworkType,
9497
);
9598
expect(namespaceMetadataTransaction.size).to.be.equal(182);
@@ -103,7 +106,7 @@ describe('NamespaceMetadataTransaction', () => {
103106
UInt64.fromUint(1000),
104107
new NamespaceId([2262289484, 3405110546]),
105108
1,
106-
new Uint8Array(10),
109+
emptyValue,
107110
TestNetworkType,
108111
);
109112
expect(namespaceMetadataTransaction.size).to.be.equal(182);
@@ -119,7 +122,7 @@ describe('NamespaceMetadataTransaction', () => {
119122
UInt64.fromUint(1000),
120123
new NamespaceId([2262289484, 3405110546]),
121124
1,
122-
new Uint8Array(10),
125+
emptyValue,
123126
TestNetworkType,
124127
).setMaxFee(2);
125128
expect(namespaceMetadataTransaction.maxFee.compact()).to.be.equal(364);
@@ -135,7 +138,7 @@ describe('NamespaceMetadataTransaction', () => {
135138
UInt64.fromUint(1000),
136139
new NamespaceId([2262289484, 3405110546]),
137140
1,
138-
new Uint8Array(10),
141+
emptyValue,
139142
TestNetworkType,
140143
);
141144

@@ -155,7 +158,7 @@ describe('NamespaceMetadataTransaction', () => {
155158
UInt64.fromUint(1000),
156159
new NamespaceId([2262289484, 3405110546]),
157160
1,
158-
new Uint8Array(10),
161+
emptyValue,
159162
TestNetworkType,
160163
);
161164
const resolved = namespaceMetadataTransaction.resolveAliases();
@@ -171,7 +174,7 @@ describe('NamespaceMetadataTransaction', () => {
171174
UInt64.fromUint(1000),
172175
new NamespaceId([2262289484, 3405110546]),
173176
1,
174-
new Uint8Array(10),
177+
emptyValue,
175178
TestNetworkType,
176179
);
177180
let canNotify = tx.shouldNotifyAccount(account.address);
@@ -193,7 +196,7 @@ describe('NamespaceMetadataTransaction', () => {
193196
UInt64.fromUint(1000),
194197
new NamespaceId([2262289484, 3405110546]),
195198
1,
196-
new Uint8Array(10),
199+
emptyValue,
197200
TestNetworkType,
198201
);
199202
let canNotify = tx.shouldNotifyAccount(alias);

0 commit comments

Comments
 (0)