-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(tests): add tests for blockheight and sortkey, break tests into…
… domain centric files
- Loading branch information
1 parent
ecb279d
commit 48bc897
Showing
8 changed files
with
283 additions
and
73 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
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 was deleted.
Oops, something went wrong.
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,73 @@ | ||
import { ArNSRemoteCache } from '../../src/common/caches/arns-remote-cache.js'; | ||
|
||
describe('ArNSRemoteCache ~ BALANCES', () => { | ||
const remoteCacheProvider = new ArNSRemoteCache({}); | ||
|
||
// balance tests | ||
it('should fetch a balance', async () => { | ||
const balance = await remoteCacheProvider.getBalance({ | ||
address: 'some-address', | ||
}); | ||
expect(balance).toEqual(0); | ||
}); | ||
|
||
it('should fetch all balances', async () => { | ||
const balances = await remoteCacheProvider.getBalances(); | ||
expect(balances).toBeDefined(); | ||
}); | ||
|
||
it('should return balance at a given block height', async () => { | ||
const address = '7waR8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk'; | ||
const currentBalance = 2_363_250; | ||
const transferAmount = 1000; | ||
const transferBlockHeight = 1305612; | ||
const balance = await remoteCacheProvider.getBalance({ | ||
address, | ||
blockHeight: transferBlockHeight, | ||
}); | ||
expect(balance).toEqual(currentBalance); | ||
|
||
const previousBalance = await remoteCacheProvider.getBalance({ | ||
address, | ||
blockHeight: transferBlockHeight - 1, | ||
}); | ||
expect(previousBalance).toEqual(currentBalance + transferAmount); | ||
}); | ||
|
||
it('should return balance at a given sort key', async () => { | ||
const address = '7waR8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk'; | ||
const balanceSortKey = | ||
'000001305612,0000000000000,6806919fa401ad27fd86db576ef578857bd22a11d6905324d643368069146d4e'; | ||
const balance = await remoteCacheProvider.getBalance({ | ||
address, | ||
sortKey: balanceSortKey, | ||
}); | ||
expect(balance).toEqual(2363250); | ||
}); | ||
|
||
it('should return balances at a given block height', async () => { | ||
const address = '7waR8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk'; | ||
const currentBalance = 2363250; | ||
const transferAmount = 1000; | ||
const transferBlockHeight = 1305612; | ||
const balances = await remoteCacheProvider.getBalances({ | ||
blockHeight: transferBlockHeight, | ||
}); | ||
expect(balances[address]).toEqual(currentBalance); | ||
|
||
const previousBalances = await remoteCacheProvider.getBalances({ | ||
blockHeight: transferBlockHeight - 1, | ||
}); | ||
expect(previousBalances[address]).toEqual(currentBalance + transferAmount); | ||
}); | ||
|
||
it('should return balances at a given sort key', async () => { | ||
const address = '7waR8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk'; | ||
const balanceSortKey = | ||
'000001305612,0000000000000,6806919fa401ad27fd86db576ef578857bd22a11d6905324d643368069146d4e'; | ||
const balances = await remoteCacheProvider.getBalances({ | ||
sortKey: balanceSortKey, | ||
}); | ||
expect(balances[address]).toEqual(2363250); | ||
}); | ||
}); |
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,68 @@ | ||
import { ArNSRemoteCache } from '../../src/common/caches/arns-remote-cache.js'; | ||
import { NotFound } from '../../src/common/error.js'; | ||
|
||
describe('ArNSRemoteCache ~ GATEWAYS', () => { | ||
const remoteCacheProvider = new ArNSRemoteCache({}); | ||
|
||
// gateway tests | ||
it('should be able to fetch gateways', async () => { | ||
const gateways = await remoteCacheProvider.getGateways(); | ||
expect(gateways).toBeDefined(); | ||
}); | ||
|
||
it('should should throw NotFound error on non existent gateway', async () => { | ||
const error = await remoteCacheProvider | ||
.getGateway({ | ||
address: 'some-address', | ||
}) | ||
.catch((e) => e); | ||
expect(error).toBeInstanceOf(NotFound); | ||
}); | ||
|
||
it('should return gateway state at a given block height', async () => { | ||
const blockHeight = 1372179; | ||
const address = 'usOg4jFzqinXK_ExoU5NijjEyggNA255998LNiM8Vtc'; | ||
const gateway = await remoteCacheProvider.getGateway({ | ||
address, | ||
blockHeight, | ||
}); | ||
expect(gateway).toBeDefined(); | ||
|
||
const previousGatewayState = await remoteCacheProvider | ||
.getGateway({ | ||
address, | ||
blockHeight: blockHeight - 1, | ||
}) | ||
.catch((e) => e); | ||
expect(previousGatewayState).toBeInstanceOf(NotFound); | ||
}); | ||
|
||
it('should return gateway state at a given sort key', async () => { | ||
const sortKey = | ||
'000001372179,0000000000000,1babf113056ce4d158c06f17ac8a1d0bff603dd6218dad98381d8e6d295f50a5'; | ||
const address = 'usOg4jFzqinXK_ExoU5NijjEyggNA255998LNiM8Vtc'; | ||
const gateway = await remoteCacheProvider.getGateway({ | ||
address, | ||
sortKey, | ||
}); | ||
expect(gateway).toBeDefined(); | ||
}); | ||
|
||
it('should return gateways state at a given block height', async () => { | ||
const blockHeight = 1372179; | ||
const address = 'usOg4jFzqinXK_ExoU5NijjEyggNA255998LNiM8Vtc'; | ||
const gateways = await remoteCacheProvider.getGateways({ | ||
blockHeight, | ||
}); | ||
expect(gateways[address]).toBeDefined(); | ||
}); | ||
|
||
it('should return gateways state at a given sort key', async () => { | ||
const address = 'usOg4jFzqinXK_ExoU5NijjEyggNA255998LNiM8Vtc'; | ||
const gateways = await remoteCacheProvider.getGateways({ | ||
sortKey: | ||
'000001372179,0000000000000,1babf113056ce4d158c06f17ac8a1d0bff603dd6218dad98381d8e6d295f50a5', | ||
}); | ||
expect(gateways[address]).toBeDefined(); | ||
}); | ||
}); |
Oops, something went wrong.