mirror of
https://github.com/bigchaindb/js-bigchaindb-driver.git
synced 2024-06-30 21:52:11 +02:00
commit
0462aca426
|
@ -18,7 +18,7 @@ before_install:
|
||||||
-e BIGCHAINDB_KEYPAIR_PRIVATE=5C5Cknco7YxBRP9AgB1cbUVTL4FAcooxErLygw1DeG2D
|
-e BIGCHAINDB_KEYPAIR_PRIVATE=5C5Cknco7YxBRP9AgB1cbUVTL4FAcooxErLygw1DeG2D
|
||||||
-e BIGCHAINDB_DATABASE_BACKEND=mongodb
|
-e BIGCHAINDB_DATABASE_BACKEND=mongodb
|
||||||
-e BIGCHAINDB_DATABASE_HOST=172.17.0.1
|
-e BIGCHAINDB_DATABASE_HOST=172.17.0.1
|
||||||
bigchaindb/bigchaindb:1.0.0rc1
|
bigchaindb/bigchaindb:master
|
||||||
start
|
start
|
||||||
- gem install cowsay
|
- gem install cowsay
|
||||||
- npm install -g codecov
|
- npm install -g codecov
|
||||||
|
|
|
@ -17,7 +17,7 @@ export default function makeOutput(condition, amount = '1') {
|
||||||
publicKeys.push(details.public_key)
|
publicKeys.push(details.public_key)
|
||||||
}
|
}
|
||||||
} else if (details.type === 'threshold-sha-256') {
|
} else if (details.type === 'threshold-sha-256') {
|
||||||
details.subfulfillments.map(getPublicKeys)
|
details.subconditions.map(getPublicKeys)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getPublicKeys(condition.details)
|
getPublicKeys(condition.details)
|
||||||
|
|
|
@ -33,7 +33,7 @@ export default function makeTransferTransaction(
|
||||||
const inputs = outputIndices.map((outputIndex) => {
|
const inputs = outputIndices.map((outputIndex) => {
|
||||||
const fulfilledOutput = unspentTransaction.outputs[outputIndex]
|
const fulfilledOutput = unspentTransaction.outputs[outputIndex]
|
||||||
const transactionLink = {
|
const transactionLink = {
|
||||||
'output': outputIndex,
|
'output_index': outputIndex,
|
||||||
'transaction_id': unspentTransaction.id,
|
'transaction_id': unspentTransaction.id,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,12 +22,12 @@ export default function ccJsonLoad(conditionJson) {
|
||||||
if (conditionJson.type === 'threshold-sha-256') {
|
if (conditionJson.type === 'threshold-sha-256') {
|
||||||
fulfillment = new cc.ThresholdSha256()
|
fulfillment = new cc.ThresholdSha256()
|
||||||
fulfillment.threshold = conditionJson.threshold
|
fulfillment.threshold = conditionJson.threshold
|
||||||
conditionJson.subfulfillments.forEach((subfulfillmentJson) => {
|
conditionJson.subconditions.forEach((subconditionJson) => {
|
||||||
const subfulfillment = ccJsonLoad(subfulfillmentJson)
|
const subcondition = ccJsonLoad(subconditionJson)
|
||||||
if ('getConditionUri' in subfulfillment) {
|
if ('getConditionUri' in subcondition) {
|
||||||
fulfillment.addSubfulfillment(subfulfillment)
|
fulfillment.addSubfulfillment(subcondition)
|
||||||
} else if ('serializeUri' in subfulfillment) {
|
} else if ('serializeUri' in subcondition) {
|
||||||
fulfillment.addSubcondition(subfulfillment)
|
fulfillment.addSubcondition(subcondition)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -35,9 +35,6 @@ export default function ccJsonLoad(conditionJson) {
|
||||||
if (conditionJson.type === 'ed25519-sha-256') {
|
if (conditionJson.type === 'ed25519-sha-256') {
|
||||||
fulfillment = new cc.Ed25519Sha256()
|
fulfillment = new cc.Ed25519Sha256()
|
||||||
fulfillment.publicKey = new Buffer(base58.decode(conditionJson.public_key))
|
fulfillment.publicKey = new Buffer(base58.decode(conditionJson.public_key))
|
||||||
if (conditionJson.signature) {
|
|
||||||
fulfillment.signature = new Buffer(base58.decode(conditionJson.signature))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return fulfillment
|
return fulfillment
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ export default function ccJsonify(fulfillment) {
|
||||||
'details': {
|
'details': {
|
||||||
'type': 'threshold-sha-256',
|
'type': 'threshold-sha-256',
|
||||||
'threshold': fulfillment.threshold,
|
'threshold': fulfillment.threshold,
|
||||||
'subfulfillments': fulfillment.subconditions.map((subcondition) => {
|
'subconditions': fulfillment.subconditions.map((subcondition) => {
|
||||||
const subconditionJson = ccJsonify(subcondition.body)
|
const subconditionJson = ccJsonify(subcondition.body)
|
||||||
return subconditionJson.details
|
return subconditionJson.details
|
||||||
})
|
})
|
||||||
|
@ -48,7 +48,6 @@ export default function ccJsonify(fulfillment) {
|
||||||
jsonBody.details.type = 'ed25519-sha-256'
|
jsonBody.details.type = 'ed25519-sha-256'
|
||||||
|
|
||||||
if ('publicKey' in fulfillment) {
|
if ('publicKey' in fulfillment) {
|
||||||
jsonBody.details.signature = null
|
|
||||||
jsonBody.details.public_key = base58.encode(fulfillment.publicKey)
|
jsonBody.details.public_key = base58.encode(fulfillment.publicKey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ test('Ed25519 condition encoding', t => {
|
||||||
details: {
|
details: {
|
||||||
type: 'ed25519-sha-256',
|
type: 'ed25519-sha-256',
|
||||||
public_key: publicKey,
|
public_key: publicKey,
|
||||||
signature: null,
|
|
||||||
},
|
},
|
||||||
uri: 'ni:///sha-256;uLdVX7FEjLWVDkAkfMAkEqPPwFqZj7qfiGE152t_x5c?fpt=ed25519-sha-256&cost=131072'
|
uri: 'ni:///sha-256;uLdVX7FEjLWVDkAkfMAkEqPPwFqZj7qfiGE152t_x5c?fpt=ed25519-sha-256&cost=131072'
|
||||||
}
|
}
|
||||||
|
@ -28,16 +27,14 @@ test('Threshold condition encoding', t => {
|
||||||
details: {
|
details: {
|
||||||
type: 'threshold-sha-256',
|
type: 'threshold-sha-256',
|
||||||
threshold: 1,
|
threshold: 1,
|
||||||
subfulfillments: [
|
subconditions: [
|
||||||
{
|
{
|
||||||
type: 'ed25519-sha-256',
|
type: 'ed25519-sha-256',
|
||||||
public_key: publicKey,
|
public_key: publicKey,
|
||||||
signature: null,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'ed25519-sha-256',
|
type: 'ed25519-sha-256',
|
||||||
public_key: publicKey,
|
public_key: publicKey,
|
||||||
signature: null,
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -70,3 +67,19 @@ test('Fulfillment correctly formed', t => {
|
||||||
txCreate.outputs[0].condition.uri,
|
txCreate.outputs[0].condition.uri,
|
||||||
new Buffer(msg)))
|
new Buffer(msg)))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
test('CryptoConditions JSON load', t => {
|
||||||
|
const cond = Transaction.ccJsonLoad({
|
||||||
|
type: 'threshold-sha-256',
|
||||||
|
threshold: 1,
|
||||||
|
subconditions: [{
|
||||||
|
type: 'ed25519-sha-256',
|
||||||
|
public_key: 'a'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
hash: 'a'
|
||||||
|
}],
|
||||||
|
})
|
||||||
|
t.truthy(cond.subconditions.length === 2)
|
||||||
|
})
|
||||||
|
|
|
@ -85,7 +85,7 @@ test('Create TRANSFER transaction based on CREATE transaction', t => {
|
||||||
[aliceOutput],
|
[aliceOutput],
|
||||||
[makeInputTemplate(
|
[makeInputTemplate(
|
||||||
[alice.publicKey],
|
[alice.publicKey],
|
||||||
{ output: 0, transaction_id: createTx.id }
|
{ output_index: 0, transaction_id: createTx.id }
|
||||||
)]
|
)]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ test('Create TRANSFER transaction based on TRANSFER transaction', t => {
|
||||||
[aliceOutput],
|
[aliceOutput],
|
||||||
[makeInputTemplate(
|
[makeInputTemplate(
|
||||||
[alice.publicKey],
|
[alice.publicKey],
|
||||||
{ output: 0, transaction_id: transferTx.id }
|
{ output_index: 0, transaction_id: transferTx.id }
|
||||||
)]
|
)]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user