-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! feat: add GET_ADA_HANDLE command
- Loading branch information
Showing
7 changed files
with
105 additions
and
14 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { BlockfrostServerError } from "@blockfrost/blockfrost-js"; | ||
|
||
export default [ | ||
{ | ||
testName: 'getAdaHandle success', | ||
id: 1, | ||
assets: [{ | ||
address: 'address', | ||
quantity: '1', | ||
}], | ||
result: { | ||
id: 1, | ||
type: 'message', | ||
data: 'address', | ||
}, | ||
}, | ||
{ | ||
testName: 'getAdaHandle not found', | ||
id: 1, | ||
error: new BlockfrostServerError({ | ||
error: 'error', | ||
message: 'Not found', | ||
status_code: 404, | ||
url: 'url', | ||
}), | ||
result: { | ||
id: 1, | ||
type: 'message', | ||
data: null, | ||
}, | ||
}, | ||
{ | ||
testName: 'getAdaHandle empty result', | ||
id: 1, | ||
assets: [], | ||
result: { | ||
id: 1, | ||
type: 'message', | ||
data: null, | ||
}, | ||
}, | ||
{ | ||
testName: 'getAdaHandle double minted', | ||
id: 1, | ||
assets: [ | ||
{ | ||
address: 'address1', | ||
quantity: '1', | ||
}, | ||
{ | ||
address: 'address2', | ||
quantity: '1', | ||
} | ||
], | ||
thrown: new Error('Double minted Ada Handle detected'), | ||
}, | ||
]; |
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,26 @@ | ||
import sinon from 'sinon'; | ||
import { describe, test, expect } from 'vitest'; | ||
import fixtures from '../../fixtures/getAdaHandle.js'; | ||
import { blockfrostAPI } from '../../../../src/utils/blockfrost-api.js'; | ||
import getAdaHandle from '../../../../src/methods/get-ada-handle.js'; | ||
|
||
describe('getAdaHandle', () => { | ||
for (const fixture of fixtures) { | ||
test(fixture.testName, async () => { | ||
const mock1 = fixture.assets ? | ||
sinon.stub(blockfrostAPI, 'assetsAddresses').resolves(fixture.assets) : | ||
sinon.stub(blockfrostAPI, 'assetsAddresses').rejects(fixture.error); | ||
|
||
if(fixture.result) { | ||
const result = await getAdaHandle(1, 'test', 'test'); | ||
|
||
expect(result).toBe(JSON.stringify(fixture.result)); | ||
} | ||
else { | ||
await expect(getAdaHandle(1, 'test', 'test')).rejects.toEqual(fixture.thrown); | ||
} | ||
|
||
mock1.restore(); | ||
}); | ||
} | ||
}); |