@@ -4,7 +4,7 @@ Copyright IBM Corp. All Rights Reserved.
44SPDX-License-Identifier: Apache-2.0
55*/
66
7- package interactive
7+ package interactive_test
88
99import (
1010 "context"
@@ -19,6 +19,7 @@ import (
1919 "github.com/hyperledger-labs/fabric-smart-client/platform/view/view"
2020 token2 "github.com/hyperledger-labs/fabric-token-sdk/token"
2121 "github.com/hyperledger-labs/fabric-token-sdk/token/driver"
22+ "github.com/hyperledger-labs/fabric-token-sdk/token/services/certifier/interactive"
2223 "github.com/hyperledger-labs/fabric-token-sdk/token/services/tokens"
2324 "github.com/hyperledger-labs/fabric-token-sdk/token/token"
2425 "github.com/stretchr/testify/assert"
@@ -90,13 +91,13 @@ func (f *fakeViewManager) InitiateView(v view.View) (interface{}, error) {
9091 }
9192
9293 // Build a success result using the IDs from the CertificationRequestView.
93- crv , ok := v .(* CertificationRequestView )
94+ crv , ok := v .(* interactive. CertificationRequestView )
9495 if ! ok {
9596 return nil , errors .Errorf ("unexpected view type %T" , v )
9697 }
9798
98- result := make (map [* token.ID ][]byte , len (crv . ids ))
99- for _ , id := range crv . ids {
99+ result := make (map [* token.ID ][]byte , len (interactive . CRVIDs ( crv ) ))
100+ for _ , id := range interactive . CRVIDs ( crv ) {
100101 result [id ] = []byte ("cert:" + id .TxId )
101102 }
102103
@@ -120,15 +121,15 @@ var _ = (*fakeViewManager).callCount
120121// newTestClient creates a CertificationClient with defaults suitable for tests.
121122func newTestClient (
122123 t * testing.T ,
123- vm ViewManager ,
124- storage CertificationStorage ,
124+ vm interactive. ViewManager ,
125+ storage interactive. CertificationStorage ,
125126 batchSize int ,
126127 flushInterval time.Duration ,
127128 workers int ,
128- ) * CertificationClient {
129+ ) * interactive. CertificationClient {
129130 t .Helper ()
130131
131- return NewCertificationClient (
132+ return interactive . NewCertificationClient (
132133 context .Background (),
133134 "test-network" ,
134135 "test-channel" ,
@@ -144,15 +145,15 @@ func newTestClient(
144145 1000 ,
145146 flushInterval ,
146147 workers ,
147- DefaultResponseTimeout ,
148+ interactive . DefaultResponseTimeout ,
148149 & disabled.Provider {},
149150 )
150151}
151152
152153// injectToken sends a token ID directly into the client's input channel.
153154// This simulates what OnReceive does without going through the events system.
154- func injectToken (cc * CertificationClient , id * token.ID ) {
155- cc . tokens <- id
155+ func injectToken (cc * interactive. CertificationClient , id * token.ID ) {
156+ interactive . ClientTokensChan ( cc ) <- id
156157}
157158
158159// --- tests ---
@@ -236,7 +237,7 @@ func TestCertificationClient_OnReceive_BufferFull_DoesNotBlock(t *testing.T) {
236237 storage := newFakeCertificationStorage ()
237238
238239 // batchSize=1000 and flushInterval=10min so tokens accumulate but are never batched.
239- cc := NewCertificationClient (
240+ cc := interactive . NewCertificationClient (
240241 context .Background (),
241242 "net" , "ch" , "ns" ,
242243 & fakeQueryEngine {},
@@ -249,7 +250,7 @@ func TestCertificationClient_OnReceive_BufferFull_DoesNotBlock(t *testing.T) {
249250 2 , // tiny buffer — fills immediately
250251 10 * time .Minute ,
251252 1 ,
252- DefaultResponseTimeout ,
253+ interactive . DefaultResponseTimeout ,
253254 & disabled.Provider {},
254255 )
255256 cc .Start ()
@@ -280,7 +281,7 @@ func TestCertificationClient_PushbackNonBlocking(t *testing.T) {
280281 vm := & fakeViewManager {failErr : errors .New ("simulated failure" )}
281282 storage := newFakeCertificationStorage ()
282283
283- cc := NewCertificationClient (
284+ cc := interactive . NewCertificationClient (
284285 context .Background (),
285286 "net" , "ch" , "ns" ,
286287 & fakeQueryEngine {},
@@ -294,7 +295,7 @@ func TestCertificationClient_PushbackNonBlocking(t *testing.T) {
294295 1 , // bufferSize=1 — push-back will overflow
295296 20 * time .Millisecond ,
296297 1 ,
297- DefaultResponseTimeout ,
298+ interactive . DefaultResponseTimeout ,
298299 & disabled.Provider {},
299300 )
300301 cc .Start ()
@@ -327,7 +328,7 @@ func TestCertificationClient_MultipleWorkers(t *testing.T) {
327328
328329 storage := newFakeCertificationStorage ()
329330
330- cc := NewCertificationClient (
331+ cc := interactive . NewCertificationClient (
331332 context .Background (),
332333 "net" , "ch" , "ns" ,
333334 & fakeQueryEngine {},
@@ -340,7 +341,7 @@ func TestCertificationClient_MultipleWorkers(t *testing.T) {
340341 1000 ,
341342 5 * time .Millisecond ,
342343 workers ,
343- DefaultResponseTimeout ,
344+ interactive . DefaultResponseTimeout ,
344345 & disabled.Provider {},
345346 )
346347 cc .Start ()
@@ -399,7 +400,7 @@ func TestCertificationClient_TimerResets_MultipleFlushes(t *testing.T) {
399400
400401// countingViewManager wraps a fakeViewManager and counts successful certifications.
401402type countingViewManager struct {
402- inner ViewManager
403+ inner interactive. ViewManager
403404 counter * atomic.Int32
404405}
405406
0 commit comments