-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #449 from lightninglabs/remove-mint-lock
tapdb: allow batch inserting proofs when syncing universe, remove write lock for RegisterIssuance
- Loading branch information
Showing
23 changed files
with
998 additions
and
337 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
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,61 @@ | ||
package fn | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
var ( | ||
testTimeout = 100 * time.Millisecond | ||
) | ||
|
||
func TestCollectBatch(t *testing.T) { | ||
t.Parallel() | ||
|
||
ctxb := context.Background() | ||
ctxt, cancel := context.WithTimeout(ctxb, testTimeout) | ||
defer cancel() | ||
|
||
// First, test the expected normal case where we receive all the items | ||
// and the channel is closed. | ||
var ( | ||
c = make(chan int, 10) | ||
numReceived = 0 | ||
) | ||
|
||
for i := 0; i < 10; i++ { | ||
c <- i | ||
} | ||
close(c) | ||
|
||
err := CollectBatch( | ||
ctxt, c, 3, func(ctx context.Context, batch []int) error { | ||
numReceived += len(batch) | ||
|
||
return nil | ||
}, | ||
) | ||
require.NoError(t, err) | ||
require.Equal(t, 10, numReceived) | ||
|
||
// If we don't close the channel, then we expect to run into the | ||
// timeout and only receive 9 out of 10 items (the last batch is never | ||
// completed). | ||
c = make(chan int, 10) | ||
numReceived = 0 | ||
for i := 0; i < 10; i++ { | ||
c <- i | ||
} | ||
err = CollectBatch( | ||
ctxt, c, 3, func(ctx context.Context, batch []int) error { | ||
numReceived += len(batch) | ||
|
||
return nil | ||
}, | ||
) | ||
require.ErrorIs(t, err, context.DeadlineExceeded) | ||
require.Equal(t, 9, numReceived) | ||
} |
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
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
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
Oops, something went wrong.