1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00
squid-js/integration/ocean/SecretStore.test.ts

34 lines
774 B
TypeScript
Raw Normal View History

2019-06-20 00:20:09 +02:00
import { assert } from 'chai'
2019-02-18 15:38:49 +01:00
2019-06-20 00:20:09 +02:00
import { config } from '../config'
2019-02-18 15:38:49 +01:00
2019-06-20 00:20:09 +02:00
import { Ocean, Account, DID } from '../../src' // @oceanprotocol/squid
2019-02-18 15:38:49 +01:00
2019-06-20 00:20:09 +02:00
describe('Secret Store', () => {
2019-02-18 15:38:49 +01:00
let ocean: Ocean
let account: Account
const did: DID = DID.generate()
2019-06-20 00:20:09 +02:00
const content = { content: 'Test 123' }
2019-02-18 15:38:49 +01:00
let encryptedContent
before(async () => {
ocean = await Ocean.getInstance(config)
// Accounts
2019-06-24 13:06:38 +02:00
;[account] = await ocean.accounts.list()
2019-02-18 15:38:49 +01:00
})
2019-06-20 00:20:09 +02:00
it('should encrypt a text', async () => {
encryptedContent = await ocean.secretStore.encrypt(
did.getId(),
content,
account
)
2019-02-18 15:38:49 +01:00
assert.isDefined(encryptedContent)
assert.match(encryptedContent, /^0x[a-f0-9]{76}$/i)
2019-02-18 15:38:49 +01:00
})
})