Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: transaction builder verification #1055

Merged
merged 8 commits into from Oct 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -13,6 +13,25 @@ beforeEach(() => {
})

describe('Delegate Registration Transaction', () => {
describe('verify', () => {
it('should be valid with a signature', () => {
const actual = builder
.usernameAsset('homer')
.sign('dummy passphrase')

expect(actual.build().verify()).toBeTrue()
})

it('should be valid with a second signature', () => {
const actual = builder
.usernameAsset('homer')
.sign('dummy passphrase')
.secondSign('dummy passphrase')

expect(actual.build().verify()).toBeTrue()
})
})

transactionBuilderTests()

it('should have its specific properties', () => {
Expand Down
Expand Up @@ -13,6 +13,27 @@ beforeEach(() => {
})

describe('Multi Signature Transaction', () => {
describe('verify', () => {
it('should be valid with a signature', () => {
const actual = builder
.multiSignatureAsset({
keysgroup: [
'+0376982a97dadbc65e694743d386084548a65431a82ce935ac9d957b1cffab2784',
'+03793904e0df839809bc89f2839e1ae4f8b1ea97ede6592b7d1e4d0ee194ca2998',
'+03e710267cdbc87cf8c2f32a6c3f22e1d1ce22ba30e1915360f511a2b16df8c5a5'
],
lifetime: 72,
min: 2
})
.sign('dummy passphrase')
.multiSignatureSign('multi passphrase 1')
.multiSignatureSign('multi passphrase 2')
.multiSignatureSign('multi passphrase 3')

expect(actual.build().verify()).toBeTrue()
})
})

transactionBuilderTests()

it('should have its specific properties', () => {
Expand Down
Expand Up @@ -13,6 +13,16 @@ beforeEach(() => {
})

describe('Second Signature Transaction', () => {
describe('verify', () => {
it('should be valid with a signature', () => {
const actual = builder
.signatureAsset('signature')
.sign('dummy passphrase')

expect(actual.build().verify()).toBeTrue()
})
})

transactionBuilderTests()

it('should have its specific properties', () => {
Expand Down
23 changes: 23 additions & 0 deletions packages/crypto/__tests__/builder/transactions/transfer.test.js
Expand Up @@ -12,6 +12,29 @@ beforeEach(() => {
})

describe('Transfer Transaction', () => {
describe('verify', () => {
it('should be valid with a signature', () => {
const actual = builder
.recipientId('D5q7YfEFDky1JJVQQEy4MGyiUhr5cGg47F')
.amount(1)
.vendorField('dummy')
.sign('dummy passphrase')

expect(actual.build().verify()).toBeTrue()
})

it('should be valid with a second signature', () => {
const actual = builder
.recipientId('D5q7YfEFDky1JJVQQEy4MGyiUhr5cGg47F')
.amount(1)
.vendorField('dummy')
.sign('dummy passphrase')
.secondSign('dummy passphrase')

expect(actual.build().verify()).toBeTrue()
})
})

transactionBuilderTests()

it('should have its specific properties', () => {
Expand Down
19 changes: 19 additions & 0 deletions packages/crypto/__tests__/builder/transactions/vote.test.js
Expand Up @@ -13,6 +13,25 @@ beforeEach(() => {
})

describe('Vote Transaction', () => {
describe('verify', () => {
it('should be valid with a signature', () => {
const actual = builder
.votesAsset(['+02d0d835266297f15c192be2636eb3fbc30b39b87fc583ff112062ef8ae1a1f2af'])
.sign('dummy passphrase')

expect(actual.build().verify()).toBeTrue()
})

it('should be valid with a second signature', () => {
const actual = builder
.votesAsset(['+02d0d835266297f15c192be2636eb3fbc30b39b87fc583ff112062ef8ae1a1f2af'])
.sign('dummy passphrase')
.secondSign('dummy passphrase')

expect(actual.build().verify()).toBeTrue()
})
})

transactionBuilderTests()

it('should have its specific properties', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/crypto/lib/builder/transactions/transaction.js
Expand Up @@ -195,7 +195,7 @@ module.exports = class TransactionBuilder {
const { data } = this

Object.keys(data).forEach(key => {
if (['model', 'id'].includes(key)) {
if (['model', 'network', 'id'].includes(key)) {
delete data[key]
}
})
Expand Down