const tg = require('./target/timegraph_nodejs') test('Use correct timegraph version', () => expect(tg.version()).toBe("1.0.0")); const user_sk = "3DMtcbkZFQKxgDQzvBhWXmXwtiNafbTzbreTsaSqBWmd" const user_pk = tg.get_pubkey_of(user_sk) const user_key = "FBKes1sAFUH2nNHQEsRVCByTaiQbr4saFqYVdmjzP8SZ" const user_secret = "8i1pBz9okxy4sawgVktuD7fHStAYRiPihWpvn5LpHE8z" const user_cert = "111CfKkxwN6abZhc12s5oayLhNivoijzHX6WtmyS2oVgkcoiFdk8NzVoT5sGU8Skb7Z7pZwvQh2UPfxvdpGjgK3bfq49NrgSz2oopzYsmfXG9wMpKanojrs77epGpL3Maj8jDpdrG1KQzPXpxFbpXnnswzRPBDqA8LD6DDkYJajz7DX5qYRf7bgwA3hrtyeUXoUy4cpeJhFff5AHKiHtk3ciZ3rrCzGoRC2bJyfjko4Sf8gsrnfr2jjDWjMjvn6F9u4iT2wjHfiRVbpgKWKue9WeeSQHhFLEgi9jtVRx8VkJE2vxjZ3EZtazh3DHor7A4iM7JtN74rw5M3kmDH47fsvYM7hWHnS7qbyfmpYJZzbfGAQbg3aUZ7MChvzKZT9cxyD9oz3Seda6GQM85wUxG8ytT97KUEZhsf9AK51nYrVRUPthWvVN3NbbPpznNgBDiuWcttyrNcTsnPaBVBgmf1QwULyRzKmi2hXVz1bFacj8rEETuRs7qp2JvT7oEamKwN8dFKXvgkXuiMJj5vWbPFrJTrDWTdJQnUGvd4Q6UPESYCnnDmxR5HtQzaWy83NJPRuZW8ZUAfJzf4oLjK1UkYv4g5EUvwiCiQFfsyyfaYRCrLYdv8rDzpaGt3RbeScJwcWY3o2R23aJ2W5GE943UxREiYeZ2SxA9SSygZjFY6fPQRjRFwshvjyYJgbrcXPjfcyx2wYstqsaYvW" test('Create/Verify session key', () => { const ssk = tg.new_ssk({ns: 0, key: user_key, secret: user_secret, expiration: 0 }); expect(tg.verify_ssk(ssk)).toStrictEqual({ns:0, key: user_key, expiration: 0, user_id: undefined}); }) test('Create/Verify session system key', () => { const ssk = tg.new_ssk({ns: 0, key: user_key, user_id: 102, secret: user_secret, expiration: 0 }); expect(tg.verify_ssk(ssk)).toStrictEqual({ns:0, key: user_key, expiration: 0, user_id: 102}); }) test('Create/Verify session wallet key', () => { const ssk = tg.new_ssk({ns: 0, key: user_key, user_id: 1, secret: user_secret, expiration: 0 }); expect(tg.verify_ssk(ssk)).toStrictEqual({ns:0, key: user_key, expiration: 0, user_id: 1}); }) test('Verify Predefined Cert', () => { const cert = tg.verify_cert(user_cert); expect(cert.owner).toStrictEqual(user_pk); expect(cert.delegate).toStrictEqual(user_key); expect(cert.role).toStrictEqual('developer'); }) describe('With new API key', () => { apikey = tg.new_apikey(user_sk,'developer'); test('Verify Cert', () => { const cert = tg.verify_cert(apikey.cert); expect(cert.owner).toStrictEqual(user_pk); expect(cert.delegate).toStrictEqual(apikey.key); expect(cert.role).toStrictEqual('developer'); }); test('Verify session key', () => { const ssk = tg.new_ssk({ns: 0, key: apikey.key, secret: apikey.secret, expiration: 0}); expect(tg.verify_ssk(ssk)).toStrictEqual({ns: 0, key: apikey.key, expiration: 0, user_id: undefined}); }); })