Nikhil has a test for the same (0004-Teach-test_decoding-plugin-to-work-with-2PC.Jan4) in his last email [1]. You might want to use it to test this behavior. I think you can also keep the tests as a separate patch as Nikhil had.
Done. I've added the tests and also tweaked code to make sure that the aborts during 2 phase commits are also handled.
I don't know why the patch has used this way to implement an option to enable two-phase. Can't we use how we implement 'stream-changes' option in commit 7259736a6e? Just refer how we set ctx->streaming and you can use a similar way to set this parameter.
Done, I've moved the checks for callbacks to inside the corresponding wrappers.