Open YOU54F opened 4 months ago
From the perspective of the FFI, I would first question whether we need to both function at all? Or should we deprecate one in favour of the other?
Having said that, if we do decide to keep both, I agree they should probably produce the same result.
Do you know which one is the more correct output? I'm guessing that pactffi_pact_handle_write_file
is incorrect since, as you put it, it is missing the transport
key?
I hadn't seen pactffi_pact_handle_write_file
before, but it was used in pact-net and I have been looking at the work to incorporate plugins into pact-net.
I think it might be because its a message pact handle I get back from pactffi_new_sync_message_interaction
and pactffi_pact_handle_write_file
requires a pact handle.
`pact_ffi_write_pact looks correct to me (in the fact the transport key is written which allows plugins to be used on the verification side)
I don't think pactffi_with_specification
is suitable for the message pact handle and aligns with some of the message handle confusion you and me have had recently
Yeah, this definitely seems to link with #440.
From the recent work in Pact Python, I can confirm that it is possible to use message interactions without using MessagePactHandle
and MessageHandle
(using, instead PactHandle
and InteractionHandle
respectively).
Found the root cause of the problem.
pactffi_write_pact_file
calls pact_mock_server::write_pact_file
which retrieves the plugin mock server Pact and then writes it out. The plugin mock server knows all about the transport being used and can set that field.
pactffi_pact_handle_write_file
writes out the Pact stored with the handle. It is generic, and knows nothing about plugins and transports.
Expected - Calling
pactffi_pact_handle_write_file
will result in the same pact file aspactffi_write_file
Actual - Calling
pactffi_pact_handle_write_file
will result in a pact file, with a missingtransport
key in the plugin interactionReproducer - https://github.com/pact-foundation/pact-reference/compare/master...YOU54F:pact-reference:bug/pactffi_pact_handle_write_file_no_transport
The test skips sending a consumer request, and checking mismatches, and simply aims to serialise the file after starting the mock server. Sending a valid consumer request does not change the outcome
Uncomment
pactffi_pact_handle_write_file
and comment outpactffi_write_pact_file
linw to see an errorrelevant code
pact_ffi_write_pact
pact_mock_server::write_pact_file
pact_handle_write_pact_file
use pact_models::pact::{ReadWritePact, write_pact};