you have bought a used engine which has piston slap and bad timing chain tensioner probably, a classic issue on toyota 1KR. What this means is that.
this engine will develop these noises as they age, and can be repaired to new spec. Buying a used engine guarnatees that you will get an engine wth these noises already present.
You can identify a lot of noises just by using a stethescope - if you hear a knocking noise while going over bumps, its probably chassis related like arms etc. If you hear it at idle then first try isolating stuff that is spinning externally (meaning remove the belt and test) - knocking noise can be from a bad AC compressor too as it can be from the belt tensioner too.
But - as Raja Atta said - buying scrap literally means you are buying scrap (translated to kabaar maal - aka teen dabba etc) - dont expect brand new service life from it.