fix(slp): Removing the data2 path as it never worked well

This commit is contained in:
Chris Troutner
2025-11-16 07:38:35 -08:00
parent f59ca87f1e
commit c338fd38ea
6 changed files with 1 additions and 114 deletions
@@ -92,7 +92,6 @@ describe('#controllers/rest-api/index.js', () => {
getTxid: () => {},
getTokenStats: () => {},
getTokenData: () => {},
getTokenData2: () => {},
getMutableCid: () => {},
decodeOpReturn: () => {},
getCIDData: () => {}
+1 -58
View File
@@ -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' })
})
})
})
-15
View File
@@ -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)