The present work presents a fully comprehensive implementation of wave generation and active wave absorption for second-order long-crested monochromatic and random waves in a WCSPH-based (Weakly Compressible Smoothed Particle Hydrodynamics) model. The open-source code DualSPHysics is used for the scope. The numerical flume resembles a physical wave facility, so that, the moving boundaries mimic the action of a piston-type wavemaker. The second-order wave generation system, capable of generating both monochromatic (regular) and random (irregular) waves, is implemented jointly with passive and active wave absorption. A damping system is defined as solution for passive absorption and is used to prevent wave reflection from fixed boundaries in the numerical flume. The use of active wave absorption allows avoiding spurious reflection from the wavemaker. These implementations are validated with theoretical solutions and experimental results, in terms of water surface elevation, wave orbital velocities, wave forces and capacity for damping the re-reflection inside the fluid domain.