Show!!! To adicionando aqui e o script caiu no primeiro if. Acho que para esse primero check deveria ser:
if (
totalContentsBeforeTabcoins.rows.length !==
totalContentsTabcoinsAfter.rows[0].sum - totalContentsTabcoinsBefore.rows[0].sum
) {
throw new UnprocessableEntityError({
message: 'Number of added Content TabCoins does not match',
context: {
totalContentsBeforeTabcoins: totalContentsBeforeTabcoins.rows.length,
totalContentsTabcoinsBefore: totalContentsTabcoinsBefore.rows[0].sum,
totalContentsTabcoinsAfter: totalContentsTabcoinsAfter.rows[0].sum,
addedTabCoins: totalContentsTabcoinsAfter.rows[0].sum - totalContentsTabcoinsBefore.rows[0].sum,
},
});
Porque no final das contas, o totalContentsBeforeTabcoins
(conteúdos criados antes das TabCoins) deveria ser o mesmo número das TabCoins adicionadas, que é a subtração de totalContentsTabcoinsAfter
com totalContentsTabcoinsBefore
.
O que acha?