-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 340: Content hash is out of spec in announcements (#343)
# Problem Content watcher bug #340 in calculating `contentHash`, ## Details - [x] Updated content-watcher to calculate correct contentHash - [x] Updated content-watcher - [x] Update app template (if needed): Note: social app template simply uses contentHash as key and do not really do any hash validation so no updates necessary Closes: #340 # Solution What I/we did to solve this problem Fixed by following DSNP spec and hashing the bytes of content in line with DSNP --------- Co-authored-by: Joe Caputo <joseph.caputo@amplica.io> Co-authored-by: Wil Wade <wil.wade@amplica.io>
- Loading branch information
1 parent
393fa3b
commit 933f46d
Showing
5 changed files
with
71 additions
and
22 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
43 changes: 43 additions & 0 deletions
43
services/content-publishing/libs/common/src/utils/ipfs.client.spec.ts
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,43 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { IpfsService } from './ipfs.client'; | ||
import { ConfigService } from '#libs/config'; | ||
import { Logger } from '@nestjs/common'; | ||
|
||
jest.mock('axios'); | ||
|
||
describe('IpfsService Tests', () => { | ||
let service: IpfsService; | ||
let configService: ConfigService; | ||
let logger: Logger; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
providers: [ | ||
IpfsService, | ||
{ | ||
provide: ConfigService, | ||
useValue: { | ||
ipfsEndpoint: 'http://localhost:5001', | ||
ipfsBasicAuthUser: '', | ||
ipfsBasicAuthSecret: '', | ||
ipfsGatewayUrl: 'http://localhost:8080/ipfs/[CID]', | ||
}, | ||
}, | ||
], | ||
}).compile(); | ||
|
||
service = module.get<IpfsService>(IpfsService); | ||
configService = module.get<ConfigService>(ConfigService); | ||
logger = new Logger(IpfsService.name); | ||
}); | ||
|
||
|
||
it('should be defined', () => { | ||
expect(service).toBeDefined(); | ||
}); | ||
|
||
it("hashes blake2b correctly ABC", async () => { | ||
const mb = await service.ipfsHashBuffer(Buffer.from("abc")); | ||
expect(mb).toMatch("bciqlu6awx6hqdt7kifaubxs5vyrchmadmgrzmf32ts2bb73b6iablli"); | ||
}); | ||
}); |
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