Skip to content

Commit

Permalink
Merge pull request #1423 from kaleido-io/ffi
Browse files Browse the repository at this point in the history
Call ResolveFFI from GenerateFFI
  • Loading branch information
nguyer authored Nov 8, 2023
2 parents 854df6c + 8759f8c commit 951e655
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
6 changes: 5 additions & 1 deletion internal/contracts/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,11 @@ func (cm *contractManager) checkParamSchema(ctx context.Context, name string, in

func (cm *contractManager) GenerateFFI(ctx context.Context, generationRequest *fftypes.FFIGenerationRequest) (*fftypes.FFI, error) {
generationRequest.Namespace = cm.namespace
return cm.blockchain.GenerateFFI(ctx, generationRequest)
ffi, err := cm.blockchain.GenerateFFI(ctx, generationRequest)
if err == nil {
err = cm.ResolveFFI(ctx, ffi)
}
return ffi, err
}

func (cm *contractManager) getDefaultContractListenerOptions() *core.ContractListenerOptions {
Expand Down
15 changes: 14 additions & 1 deletion internal/contracts/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3554,12 +3554,25 @@ func TestGenerateFFI(t *testing.T) {
cm := newTestContractManager()
mbi := cm.blockchain.(*blockchainmocks.Plugin)
mbi.On("GenerateFFI", mock.Anything, mock.Anything).Return(&fftypes.FFI{
Name: "generated",
Name: "generated",
Version: "1.0",
Methods: []*fftypes.FFIMethod{
{
Name: "method1",
},
{
Name: "method1",
},
},
}, nil)
ffi, err := cm.GenerateFFI(context.Background(), &fftypes.FFIGenerationRequest{})
assert.NoError(t, err)
assert.NotNil(t, ffi)
assert.Equal(t, "generated", ffi.Name)
assert.Equal(t, "method1", ffi.Methods[0].Name)
assert.Equal(t, "method1", ffi.Methods[0].Pathname)
assert.Equal(t, "method1", ffi.Methods[1].Name)
assert.Equal(t, "method1_1", ffi.Methods[1].Pathname)
}

type MockFFIParamValidator struct{}
Expand Down

0 comments on commit 951e655

Please sign in to comment.