Priyaranjan Mudliar
05/15/2023, 2:27 PMpactffi_new_pact
is defined as this in the pact.h file:
typedef uint16_t PactHandle;
The problem is when i am calling pactffi_create_mock_server_for_transport
with PactHandle as lets say 1 (uint16_t
) , it returns me -1 which means An invalid handle was received. Handles should be created with pactffi_new_pact
Am i missing something here? Thanks in advance
Edit: I am writing wrappers for these functions in C, so that I can then finally use Erlang NIFs to call these wrapper functionsYousaf Nabi (pactflow.io)
pactffi_new_pact
and passed the result (which is the interaction handle) to pactffi_create_mock_server_for_transport
Priyaranjan Mudliar
05/15/2023, 2:43 PMpactffi_new_pact
, then I am storing the returned value in my erlang code, then again invoking pact_ffi_new_interaction(PactHandle, Description) from my erlang code which then invokes my c code. My sample C code for pact_ffi_new_interaction looks like this:
static ERL_NIF_TERM erl_pactffi_new_interaction(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
unsigned int len1;
enif_get_list_length(env, argv[1], &len1);
char *buf1 ; // This is my interaction description
buf1 = (char *)malloc(len1 * sizeof(char));
if (!enif_get_string(env, argv[1], buf1, sizeof(buf1), ERL_NIF_LATIN1)) {
return enif_make_badarg(env);
}
int ip; // This is my PactHandle
if (!enif_get_int(env, argv[0], &ip)) {
return enif_make_badarg(env);
}
PactHandle pacthandle = ip;
InteractionHandle interactionhandle = pactffi_new_interaction(pacthandle, buf1);
return enif_make_int(env, interactionhandle);
}
Priyaranjan Mudliar
05/15/2023, 2:44 PMpactffi_create_mock_server_for_transport
from where I am creating the pactffi_new_pact
right ?Priyaranjan Mudliar
05/15/2023, 2:46 PMPriyaranjan Mudliar
05/15/2023, 3:20 PMPriyaranjan Mudliar
05/15/2023, 6:03 PMYousaf Nabi (pactflow.io)