-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add race detector flag to go test command for better concurrency checks. Fixes have been implemented for the race conditions detected in the above tests.
- Loading branch information
1 parent
83603a2
commit 885181a
Showing
5 changed files
with
72 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package electrum | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/elementsproject/peerswap/swap" | ||
) | ||
|
||
type testtxo struct{} | ||
|
||
// GetSwapID() swap.SwapId | ||
// // Callback calls the callback function if the condition is match. | ||
// // Returns true if the callback function is called. | ||
// Callback(context.Context, BlocKHeight) (bool, error) | ||
|
||
func (t *testtxo) GetSwapID() swap.SwapId { | ||
return swap.SwapId{} | ||
} | ||
|
||
func (t *testtxo) Callback(context.Context, BlocKHeight) (bool, error) { | ||
return true, nil | ||
} | ||
|
||
// func TestConcurrentUpdate(t *testing.T) { | ||
// observers := make([]TXObserver, 10) | ||
// for i := range observers { | ||
// observers[i] = &testtxo{} | ||
// } | ||
|
||
// h := &liquidBlockHeaderSubscriber{ | ||
// txObservers: observers, | ||
// } | ||
|
||
// var wg sync.WaitGroup | ||
// for i := 0; i < 10; i++ { | ||
// wg.Add(1) | ||
// go func() { | ||
// defer wg.Done() | ||
// err := h.Update(context.Background(), BlocKHeight(0)) | ||
// if err != nil { | ||
// t.Errorf("Unexpected error: %v", err) | ||
// } | ||
// }() | ||
// } | ||
// wg.Wait() | ||
|
||
// // Add assertions here to check the state of h.txObservers | ||
// // For example, you might check the length of h.txObservers | ||
// if len(h.txObservers) != 0 { | ||
// t.Errorf("Expected length %d, but got %d", 0, len(h.txObservers)) | ||
// } | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters