Skip to content

Commit

Permalink
Fixed unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaszslabon committed Mar 15, 2024
1 parent 287bffd commit 13d5927
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion pkg/tbtc/chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ type localChain struct {
movingFundsProposalValidationsMutex sync.Mutex
movingFundsProposalValidations map[[32]byte]bool

movedFundsSweepRequestsMutex sync.Mutex
movedFundsSweepRequests map[[32]byte]*MovedFundsSweepRequest

movedFundsSweepProposalValidationsMutex sync.Mutex
movedFundsSweepProposalValidations map[[32]byte]bool

Expand Down Expand Up @@ -202,11 +205,39 @@ func (lc *localChain) IsBetaOperator() (bool, error) {
panic("unsupported")
}

func buildMovedFundsSweepRequestKey(
movingFundsTxHash bitcoin.Hash,
movingFundsTxOutpointIndex uint32,
) [32]byte {
var buffer bytes.Buffer

buffer.Write(movingFundsTxHash[:])

outputIndex := make([]byte, 4)
binary.BigEndian.PutUint32(outputIndex, movingFundsTxOutpointIndex)
buffer.Write(outputIndex)

return sha256.Sum256(buffer.Bytes())
}

func (lc *localChain) GetMovedFundsSweepRequest(
movingFundsTxHash bitcoin.Hash,
movingFundsTxOutpointIndex uint32,
) (*MovedFundsSweepRequest, bool, error) {
panic("unsupported")
lc.movedFundsSweepRequestsMutex.Lock()
defer lc.movedFundsSweepRequestsMutex.Unlock()

requestKey := buildMovedFundsSweepRequestKey(
movingFundsTxHash,
movingFundsTxOutpointIndex,
)

request, ok := lc.movedFundsSweepRequests[requestKey]
if !ok {
return nil, false, nil
}

return request, true, nil
}

func (lc *localChain) GetOperatorID(
Expand Down

0 comments on commit 13d5927

Please sign in to comment.