Skip to content

Commit

Permalink
test: add unit tests for classic signature requirements pipeline (#115)
Browse files Browse the repository at this point in the history
* Adjustments to release library as open source 🚀  (#107)

* chore: add jest setup to coverage all files (#101)

* refactor: fix circular import

* test: contract engine initial structure

* Contract Engine unit tests (#103)

* refactor: contract engine errors

* feat: validate required initialization arguments

* test: contract engine initialization workflow

* test: complete contract engine main coverage

* refactor: update deprecated methods

* refactor: contract engine errors (#104)

* Update docs and minor adjustments to jsdocs (#105)

* fix: missing error CE009

* docs: update jsdoc

* docs: update readme for public release

* packaging: bump version to 0.7.0 (#108)

---------

Co-authored-by: Bruno Nascimento <[email protected]>

* fix: setoptions op threshold requirement

* fix: revoke operation variants threshold calculation

* test: add unit tests to classig sign requirements pipeline

* refactor: rearrange as per aaa pattern

---------

Co-authored-by: Bruno Nascimento <[email protected]>
  • Loading branch information
fazzatti and Brunonascdev authored Apr 1, 2024
1 parent d8924db commit 88a8b0a
Show file tree
Hide file tree
Showing 2 changed files with 470 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/stellar-plus/core/pipelines/classic-sign-requirements/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class ClassicSignRequirementsPipeline extends ConveyorBelt<

let thresholdLevel = SignatureThreshold.medium

switch (operation.type) {
switch (operation.type as string) {
case xdr.OperationType.createAccount().name:
return {
publicKey: setSourceSigner(operation.source),
Expand Down Expand Up @@ -121,11 +121,11 @@ export class ClassicSignRequirementsPipeline extends ConveyorBelt<

case xdr.OperationType.setOptions().name:
if (
!(operation as Operation.SetOptions).masterWeight &&
!(operation as Operation.SetOptions).signer &&
!(operation as Operation.SetOptions).lowThreshold &&
!(operation as Operation.SetOptions).medThreshold &&
!(operation as Operation.SetOptions).highThreshold
(operation as Operation.SetOptions).masterWeight ||
(operation as Operation.SetOptions).signer ||
(operation as Operation.SetOptions).lowThreshold ||
(operation as Operation.SetOptions).medThreshold ||
(operation as Operation.SetOptions).highThreshold
) {
thresholdLevel = SignatureThreshold.high
}
Expand All @@ -150,7 +150,7 @@ export class ClassicSignRequirementsPipeline extends ConveyorBelt<
case xdr.OperationType.accountMerge().name:
return {
publicKey: setSourceSigner(operation.source),
thresholdLevel,
thresholdLevel: SignatureThreshold.high,
}

case xdr.OperationType.manageData().name:
Expand Down Expand Up @@ -190,6 +190,13 @@ export class ClassicSignRequirementsPipeline extends ConveyorBelt<
}

case xdr.OperationType.revokeSponsorship().name:
case 'revokeAccountSponsorship':
case 'revokeTrustlineSponsorship':
case 'revokeOfferSponsorship':
case 'revokeDataSponsorship':
case 'revokeClaimableBalanceSponsorship':
case 'revokeLiquidityPoolSponsorship':
case 'revokeSignerSponsorship':
return {
publicKey: setSourceSigner(operation.source),
thresholdLevel,
Expand Down
Loading

0 comments on commit 88a8b0a

Please sign in to comment.