Skip to content

Commit

Permalink
v14.15.0: solana mock transaction.transaction.signatures + transactio…
Browse files Browse the repository at this point in the history
…n.transaction.message.compiledInstructions
  • Loading branch information
10xSebastian committed Aug 2, 2023
1 parent 3e53b9f commit aa59915
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 10 deletions.
7 changes: 6 additions & 1 deletion dist/esm/index.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -66323,7 +66323,12 @@ let getConfirmedTransaction = ({ signature }) => {
return({
blockTime: 1658913018,
slot: 143351809,
transaction: {},
transaction: {
signatures: [mock.transaction._id],
message: {
compiledInstructions: mock.transaction.compiledInstructions ? mock.transaction.compiledInstructions : []
}
},
meta: {
err: mock.transaction._failed ? { InstructionError: [0, 'Error'] } : null,
logMessages: mock.transaction._failedReason ? [mock.transaction._failedReason] : (mock.transaction.logMessages || [])
Expand Down
7 changes: 6 additions & 1 deletion dist/esm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1930,7 +1930,12 @@ let getConfirmedTransaction = ({ signature }) => {
return({
blockTime: 1658913018,
slot: 143351809,
transaction: {},
transaction: {
signatures: [mock.transaction._id],
message: {
compiledInstructions: mock.transaction.compiledInstructions ? mock.transaction.compiledInstructions : []
}
},
meta: {
err: mock.transaction._failed ? { InstructionError: [0, 'Error'] } : null,
logMessages: mock.transaction._failedReason ? [mock.transaction._failedReason] : (mock.transaction.logMessages || [])
Expand Down
7 changes: 6 additions & 1 deletion dist/esm/index.solana.js
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,12 @@ let getConfirmedTransaction = ({ signature }) => {
return({
blockTime: 1658913018,
slot: 143351809,
transaction: {},
transaction: {
signatures: [mock.transaction._id],
message: {
compiledInstructions: mock.transaction.compiledInstructions ? mock.transaction.compiledInstructions : []
}
},
meta: {
err: mock.transaction._failed ? { InstructionError: [0, 'Error'] } : null,
logMessages: mock.transaction._failedReason ? [mock.transaction._failedReason] : (mock.transaction.logMessages || [])
Expand Down
7 changes: 6 additions & 1 deletion dist/umd/index.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -66331,7 +66331,12 @@
return({
blockTime: 1658913018,
slot: 143351809,
transaction: {},
transaction: {
signatures: [mock.transaction._id],
message: {
compiledInstructions: mock.transaction.compiledInstructions ? mock.transaction.compiledInstructions : []
}
},
meta: {
err: mock.transaction._failed ? { InstructionError: [0, 'Error'] } : null,
logMessages: mock.transaction._failedReason ? [mock.transaction._failedReason] : (mock.transaction.logMessages || [])
Expand Down
7 changes: 6 additions & 1 deletion dist/umd/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1936,7 +1936,12 @@
return({
blockTime: 1658913018,
slot: 143351809,
transaction: {},
transaction: {
signatures: [mock.transaction._id],
message: {
compiledInstructions: mock.transaction.compiledInstructions ? mock.transaction.compiledInstructions : []
}
},
meta: {
err: mock.transaction._failed ? { InstructionError: [0, 'Error'] } : null,
logMessages: mock.transaction._failedReason ? [mock.transaction._failedReason] : (mock.transaction.logMessages || [])
Expand Down
7 changes: 6 additions & 1 deletion dist/umd/index.solana.js
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,12 @@
return({
blockTime: 1658913018,
slot: 143351809,
transaction: {},
transaction: {
signatures: [mock.transaction._id],
message: {
compiledInstructions: mock.transaction.compiledInstructions ? mock.transaction.compiledInstructions : []
}
},
meta: {
err: mock.transaction._failed ? { InstructionError: [0, 'Error'] } : null,
logMessages: mock.transaction._failedReason ? [mock.transaction._failedReason] : (mock.transaction.logMessages || [])
Expand Down
2 changes: 1 addition & 1 deletion package.evm.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@depay/web3-mock-evm",
"moduleName": "Web3Mock",
"version": "14.14.2",
"version": "14.15.0",
"description": "JavaScript library to mock web3 responses either by emulating web3 wallets or web3 RPC requests.",
"main": "./dist/umd/index.evm.js",
"module": "./dist/esm/index.evm.js",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@depay/web3-mock",
"moduleName": "Web3Mock",
"version": "14.14.2",
"version": "14.15.0",
"description": "JavaScript library to mock web3 responses either by emulating web3 wallets or web3 RPC requests.",
"main": "./dist/umd/index.js",
"module": "./dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion package.solana.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@depay/web3-mock-solana",
"moduleName": "Web3Mock",
"version": "14.14.2",
"version": "14.15.0",
"description": "JavaScript library to mock web3 responses either by emulating web3 wallets or web3 RPC requests.",
"main": "./dist/umd/index.solana.js",
"module": "./dist/esm/index.solana.js",
Expand Down
7 changes: 6 additions & 1 deletion src/platforms/solana/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,12 @@ let getConfirmedTransaction = ({ signature }) => {
return({
blockTime: 1658913018,
slot: 143351809,
transaction: {},
transaction: {
signatures: [mock.transaction._id],
message: {
compiledInstructions: mock.transaction.compiledInstructions ? mock.transaction.compiledInstructions : []
}
},
meta: {
err: mock.transaction._failed ? { InstructionError: [0, 'Error'] } : null,
logMessages: mock.transaction._failedReason ? [mock.transaction._failedReason] : (mock.transaction.logMessages || [])
Expand Down
31 changes: 31 additions & 0 deletions tests/units/solana/transactions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,37 @@ describe('solana mock transactions', ()=> {
expect(status.value.confirmations).toEqual(0)

})

it('mocks transaction signatures', async ()=> {

let mockedTransaction = mock({
blockchain,
transaction: {
from: "2UgCJaHU5y8NC4uWQcZYeV9a5RyYLF7iKYCybCsdFFD1",
}
})

confirm(mockedTransaction)

let fullTransactionData = await window.solana.getTransaction(mockedTransaction.transaction._id)
expect(fullTransactionData.transaction.signatures[0]).toEqual(mockedTransaction.transaction._id)
})

it('mocks transaction compiled instructions', async ()=> {

let mockedTransaction = mock({
blockchain,
transaction: {
from: "2UgCJaHU5y8NC4uWQcZYeV9a5RyYLF7iKYCybCsdFFD1",
compiledInstructions: ['INSTRUCTION']
}
})

confirm(mockedTransaction)

let fullTransactionData = await window.solana.getTransaction(mockedTransaction.transaction._id)
expect(fullTransactionData.transaction.message.compiledInstructions[0]).toEqual('INSTRUCTION')
})
})
})
});

0 comments on commit aa59915

Please sign in to comment.