mirror of
https://github.com/Permissionless-Software-Foundation/psf-bch-api.git
synced 2026-09-21 16:52:00 -07:00
fix(slp): Removing the data2 path as it never worked well
This commit is contained in:
@@ -92,7 +92,6 @@ describe('#controllers/rest-api/index.js', () => {
|
||||
getTxid: () => {},
|
||||
getTokenStats: () => {},
|
||||
getTokenData: () => {},
|
||||
getTokenData2: () => {},
|
||||
getMutableCid: () => {},
|
||||
decodeOpReturn: () => {},
|
||||
getCIDData: () => {}
|
||||
|
||||
@@ -25,8 +25,7 @@ describe('#slp-controller.js', () => {
|
||||
getAddress: sandbox.stub().resolves({ balance: 1000 }),
|
||||
getTxid: sandbox.stub().resolves({ txid: 'abc' }),
|
||||
getTokenStats: sandbox.stub().resolves({ tokenData: {} }),
|
||||
getTokenData: sandbox.stub().resolves({ genesisData: {}, immutableData: '', mutableData: '' }),
|
||||
getTokenData2: sandbox.stub().resolves({ tokenIcon: 'test-icon.png' })
|
||||
getTokenData: sandbox.stub().resolves({ genesisData: {}, immutableData: '', mutableData: '' })
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -310,60 +309,4 @@ describe('#slp-controller.js', () => {
|
||||
assert.deepEqual(res.jsonData, { error: 'Token data not found' })
|
||||
})
|
||||
})
|
||||
|
||||
describe('#getTokenData2()', () => {
|
||||
it('should return expanded token data on success', async () => {
|
||||
const req = createMockRequest({
|
||||
body: { tokenId: 'a'.repeat(64) }
|
||||
})
|
||||
const res = createMockResponse()
|
||||
|
||||
await uut.getTokenData2(req, res)
|
||||
|
||||
assert.equal(res.statusValue, 200)
|
||||
assert.deepEqual(res.jsonData, { tokenIcon: 'test-icon.png' })
|
||||
assert.isTrue(mockUseCases.slp.getTokenData2.calledOnce)
|
||||
})
|
||||
|
||||
it('should pass updateCache flag', async () => {
|
||||
const req = createMockRequest({
|
||||
body: { tokenId: 'a'.repeat(64), updateCache: true }
|
||||
})
|
||||
const res = createMockResponse()
|
||||
|
||||
await uut.getTokenData2(req, res)
|
||||
|
||||
assert.isTrue(mockUseCases.slp.getTokenData2.calledWith({
|
||||
tokenId: 'a'.repeat(64),
|
||||
updateCache: true
|
||||
}))
|
||||
})
|
||||
|
||||
it('should return error if tokenId is empty', async () => {
|
||||
const req = createMockRequest({
|
||||
body: { tokenId: '' }
|
||||
})
|
||||
const res = createMockResponse()
|
||||
|
||||
await uut.getTokenData2(req, res)
|
||||
|
||||
assert.equal(res.statusValue, 400)
|
||||
assert.property(res.jsonData, 'error')
|
||||
})
|
||||
|
||||
it('should handle errors via handleError', async () => {
|
||||
const error = new Error('Token icon not found')
|
||||
error.status = 404
|
||||
mockUseCases.slp.getTokenData2.rejects(error)
|
||||
const req = createMockRequest({
|
||||
body: { tokenId: 'a'.repeat(64) }
|
||||
})
|
||||
const res = createMockResponse()
|
||||
|
||||
await uut.getTokenData2(req, res)
|
||||
|
||||
assert.equal(res.statusValue, 404)
|
||||
assert.deepEqual(res.jsonData, { error: 'Token icon not found' })
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -195,21 +195,6 @@ describe('#slp-use-cases.js', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('#getTokenData2()', () => {
|
||||
it('should call slpTokenMedia getIcon method', async () => {
|
||||
const tokenId = 'a'.repeat(64)
|
||||
const updateCache = false
|
||||
mockSlpTokenMedia.getIcon.resolves({ tokenIcon: 'test-icon.png' })
|
||||
|
||||
const result = await uut.getTokenData2({ tokenId, updateCache })
|
||||
|
||||
assert.isTrue(
|
||||
mockSlpTokenMedia.getIcon.calledOnceWith({ tokenId, updateCache })
|
||||
)
|
||||
assert.deepEqual(result, { tokenIcon: 'test-icon.png' })
|
||||
})
|
||||
})
|
||||
|
||||
describe('#decodeOpReturn()', () => {
|
||||
it('should decode OP_RETURN data from transaction', async () => {
|
||||
const txid = 'a'.repeat(64)
|
||||
|
||||
Reference in New Issue
Block a user