| 11 | namespace blocksci { |
| 12 | |
| 13 | class AlgorithmsTest : public BlockSciTest { |
| 14 | |
| 15 | public: |
| 16 | |
| 17 | /** |
| 18 | Iterates over all outputs on the chain and returns them if boolFunc(output) returns true. |
| 19 | */ |
| 20 | std::vector<Output> filterOutputsOnChain(std::function<bool (Output)> boolFunc) { |
| 21 | std::vector<Output> outs; |
| 22 | for(auto block : chain) { |
| 23 | for(auto tx : block) { |
| 24 | for(auto output : tx.outputs()) { |
| 25 | if(boolFunc(output)) { |
| 26 | outs.push_back(output); |
| 27 | } |
| 28 | } |
| 29 | } |
| 30 | } |
| 31 | return outs; |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | Iterates over all inputs on the chain and returns them if boolFunc(input) returns true. |
| 36 | */ |
| 37 | std::vector<Input> filterInputsOnChain(std::function<bool (Input)> boolFunc) { |
| 38 | std::vector<Input> ins; |
| 39 | for(auto block : chain) { |
| 40 | for(auto tx : block) { |
| 41 | for(auto input : tx.inputs()) { |
| 42 | if(boolFunc(input)) { |
| 43 | ins.push_back(input); |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | return ins; |
| 49 | } |
| 50 | }; |
| 51 | |
| 52 | |
| 53 | TEST_F(AlgorithmsTest, CppConceptIsBlockchain) { |
nothing calls this directly
no outgoing calls
no test coverage detected