Skip to content

Commit

Permalink
Adjust mock and add new line
Browse files Browse the repository at this point in the history
  • Loading branch information
iamacook committed Oct 25, 2024
1 parent 45a96f7 commit f18756f
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 49 deletions.
100 changes: 51 additions & 49 deletions src/domain/safe/entities/__tests__/multisig-transaction.builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,55 +13,57 @@ import { getAddress } from 'viem';
const HASH_LENGTH = 10;

export function multisigTransactionBuilder(): IBuilder<MultisigTransaction> {
const delegate = getAddress(faker.finance.ethereumAddress());
return new Builder<MultisigTransaction>()
.with('baseGas', faker.number.int())
.with('blockNumber', faker.number.int())
.with(
'confirmations',
faker.helpers.multiple(() => confirmationBuilder().build(), {
count: { min: 0, max: 5 },
}),
)
.with('confirmationsRequired', faker.number.int())
.with('data', faker.string.hexadecimal() as `0x${string}`)
.with('dataDecoded', dataDecodedBuilder().build())
.with('ethGasPrice', faker.string.hexadecimal())
.with('executor', getAddress(faker.finance.ethereumAddress()))
.with('executionDate', faker.date.recent())
.with('fee', faker.string.hexadecimal())
.with('gasPrice', faker.string.hexadecimal())
.with('gasToken', getAddress(faker.finance.ethereumAddress()))
.with('gasUsed', faker.number.int())
.with('isExecuted', faker.datatype.boolean())
.with('isSuccessful', faker.datatype.boolean())
.with('modified', faker.date.recent())
.with('nonce', faker.number.int())
.with('operation', faker.helpers.arrayElement([0, 1]) as Operation)
.with(
'origin',
`{"url": "${faker.internet.url({
appendSlash: false,
})}", "name": "${faker.word.words()}"}`,
)
.with('proposer', delegate)
.with('proposedByDelegate', delegate)
.with('refundReceiver', getAddress(faker.finance.ethereumAddress()))
.with('safe', getAddress(faker.finance.ethereumAddress()))
.with('safeTxGas', faker.number.int())
.with(
'safeTxHash',
faker.string.hexadecimal({ length: HASH_LENGTH }) as `0x${string}`,
)
.with('signatures', faker.string.hexadecimal() as `0x${string}`)
.with('submissionDate', faker.date.recent())
.with('to', getAddress(faker.finance.ethereumAddress()))
.with(
'transactionHash',
faker.string.hexadecimal({ length: HASH_LENGTH }) as `0x${string}`,
)
.with('trusted', faker.datatype.boolean())
.with('value', faker.string.numeric());
return (
new Builder<MultisigTransaction>()
.with('baseGas', faker.number.int())
.with('blockNumber', faker.number.int())
.with(
'confirmations',
faker.helpers.multiple(() => confirmationBuilder().build(), {
count: { min: 0, max: 5 },
}),
)
.with('confirmationsRequired', faker.number.int())
.with('data', faker.string.hexadecimal() as `0x${string}`)
.with('dataDecoded', dataDecodedBuilder().build())
.with('ethGasPrice', faker.string.hexadecimal())
.with('executor', getAddress(faker.finance.ethereumAddress()))
.with('executionDate', faker.date.recent())
.with('fee', faker.string.hexadecimal())
.with('gasPrice', faker.string.hexadecimal())
.with('gasToken', getAddress(faker.finance.ethereumAddress()))
.with('gasUsed', faker.number.int())
.with('isExecuted', faker.datatype.boolean())
.with('isSuccessful', faker.datatype.boolean())
.with('modified', faker.date.recent())
.with('nonce', faker.number.int())
.with('operation', faker.helpers.arrayElement([0, 1]) as Operation)
.with(
'origin',
`{"url": "${faker.internet.url({
appendSlash: false,
})}", "name": "${faker.word.words()}"}`,
)
.with('proposer', getAddress(faker.finance.ethereumAddress()))
// Not proposed by delegate
.with('proposedByDelegate', null)
.with('refundReceiver', getAddress(faker.finance.ethereumAddress()))
.with('safe', getAddress(faker.finance.ethereumAddress()))
.with('safeTxGas', faker.number.int())
.with(
'safeTxHash',
faker.string.hexadecimal({ length: HASH_LENGTH }) as `0x${string}`,
)
.with('signatures', faker.string.hexadecimal() as `0x${string}`)
.with('submissionDate', faker.date.recent())
.with('to', getAddress(faker.finance.ethereumAddress()))
.with(
'transactionHash',
faker.string.hexadecimal({ length: HASH_LENGTH }) as `0x${string}`,
)
.with('trusted', faker.datatype.boolean())
.with('value', faker.string.numeric())
);
}

export function toJson(multisigTransaction: MultisigTransaction): unknown {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ describe('MultisigTransactionExecutionDetails mapper (Unit)', () => {
}),
);
});

it('should return a MultisigExecutionDetails object with no proposedByDelegate if not present', async () => {
const chainId = faker.string.numeric();
const safe = safeBuilder().build();
Expand Down

0 comments on commit f18756f

Please sign in to comment.