fix: transaction broadcast log

This commit is contained in:
Rafael Cárdenas
2021-11-09 10:07:55 -06:00
committed by GitHub
parent b9a8c4a600
commit e1c6882975
2 changed files with 8 additions and 1 deletions

View File

@@ -220,6 +220,12 @@ export function createCoreNodeRpcProxyRouter(db: DataStore): express.Router {
proxyResp.headers.forEach((value, name) => {
res.setHeader(name, value);
});
if (proxyResp.status === 200) {
// Log the transaction id broadcast, but clone the `Response` first before parsing its body
// so we don't mess up the original response's `ReadableStream` pointers.
const parsedTxId: string = await proxyResp.clone().json();
await logTxBroadcast(parsedTxId);
}
await pipelineAsync(proxyResp.body, res);
}
});

View File

@@ -50,7 +50,8 @@ describe('v2-proxy tests', () => {
return [apiServer, apiServer.terminate] as const;
},
async (_, __, api) => {
const primaryStubbedResponse = 'success stubbed response';
const primaryStubbedResponse =
'"1659fcdc9167576eb1f2a05d0aaba5ca1aa1943892e7e6e5d3ccb3e537f1c870"';
const extraStubbedResponse = 'extra success stubbed response';
const testRequest = 'fake-tx-data';
let mockedRequestBody = 'none';